Skip to content

Commit 5ab8bf5

Browse files
committed
chore(ruff): Autofixes for ruff with Python 3.10+
uv run ruff check . --fix --show-fixes Fixed 21 errors: - src/libvcs/_internal/run.py: 2 × UP007 (non-pep604-annotation-union) 1 × UP035 (deprecated-import) 1 × UP045 (non-pep604-annotation-optional) - src/libvcs/_internal/shortcuts.py: 1 × UP035 (deprecated-import) - src/libvcs/_internal/subprocess.py: 4 × UP007 (non-pep604-annotation-union) 1 × UP035 (deprecated-import) - src/libvcs/_internal/types.py: 2 × UP007 (non-pep604-annotation-union) 1 × UP035 (deprecated-import) - src/libvcs/pytest_plugin.py: 1 × UP035 (deprecated-import) 1 × UP045 (non-pep604-annotation-optional) - src/libvcs/sync/constants.py: 1 × UP007 (non-pep604-annotation-union) - src/libvcs/url/registry.py: 1 × UP007 (non-pep604-annotation-union) 1 × UP035 (deprecated-import) - tests/url/test_registry.py: 1 × UP007 (non-pep604-annotation-union) 1 × I001 (unsorted-imports) 1 × UP035 (deprecated-import) Found 30 errors (21 fixed, 9 remaining). No fixes available (2 hidden fixes can be enabled with the `--unsafe-fixes` option).
1 parent a586b2f commit 5ab8bf5

File tree

8 files changed

+19
-34
lines changed

8 files changed

+19
-34
lines changed

src/libvcs/_internal/run.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def console_to_str(s: bytes) -> str:
3737

3838
if t.TYPE_CHECKING:
3939
_LoggerAdapter = logging.LoggerAdapter[logging.Logger]
40-
from typing_extensions import TypeAlias
40+
from typing import TypeAlias
4141
else:
4242
_LoggerAdapter = logging.LoggerAdapter
4343

@@ -98,13 +98,10 @@ def __call__(self, output: str, timestamp: datetime.datetime) -> None:
9898
if sys.platform == "win32":
9999
_ENV: TypeAlias = Mapping[str, str]
100100
else:
101-
_ENV: TypeAlias = t.Union[
102-
Mapping[bytes, StrPath],
103-
Mapping[str, StrPath],
104-
]
101+
_ENV: TypeAlias = Mapping[bytes, StrPath] | Mapping[str, StrPath]
105102

106103
_CMD = t.Union[StrPath, Sequence[StrPath]]
107-
_FILE: TypeAlias = t.Optional[t.Union[int, t.IO[t.Any]]]
104+
_FILE: TypeAlias = int | t.IO[t.Any] | None
108105

109106

110107
def run(

src/libvcs/_internal/shortcuts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from libvcs.url import registry as url_tools
1515

1616
if t.TYPE_CHECKING:
17-
from typing_extensions import TypeGuard
17+
from typing import TypeGuard
1818

1919
from libvcs._internal.run import ProgressCallbackProtocol
2020
from libvcs._internal.types import StrPath, VCSLiteral

src/libvcs/_internal/subprocess.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from .dataclasses import SkipDefaultFieldsReprMixin
5353

5454
if t.TYPE_CHECKING:
55-
from typing_extensions import TypeAlias
55+
from typing import TypeAlias
5656

5757

5858
F = t.TypeVar("F", bound=t.Callable[..., t.Any])
@@ -66,14 +66,11 @@ def __init__(self, output: str, *args: object) -> None:
6666
if sys.platform == "win32":
6767
_ENV: TypeAlias = Mapping[str, str]
6868
else:
69-
_ENV: TypeAlias = t.Union[
70-
Mapping[bytes, StrOrBytesPath],
71-
Mapping[str, StrOrBytesPath],
72-
]
73-
_FILE: TypeAlias = t.Union[None, int, t.IO[t.Any]]
74-
_TXT: TypeAlias = t.Union[bytes, str]
69+
_ENV: TypeAlias = Mapping[bytes, StrOrBytesPath] | Mapping[str, StrOrBytesPath]
70+
_FILE: TypeAlias = None | int | t.IO[t.Any]
71+
_TXT: TypeAlias = bytes | str
7572
#: Command
76-
_CMD: TypeAlias = t.Union[StrOrBytesPath, Sequence[StrOrBytesPath]]
73+
_CMD: TypeAlias = StrOrBytesPath | Sequence[StrOrBytesPath]
7774

7875

7976
@dataclasses.dataclass(repr=False)

src/libvcs/_internal/types.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,12 @@
1313
from os import PathLike
1414

1515
if t.TYPE_CHECKING:
16-
from typing_extensions import TypeAlias
16+
from typing import TypeAlias
1717

18-
StrPath: TypeAlias = t.Union[str, PathLike[str]] # stable
18+
StrPath: TypeAlias = str | PathLike[str] # stable
1919
""":class:`os.PathLike` or :class:`str`"""
2020

21-
StrOrBytesPath: TypeAlias = t.Union[
22-
str,
23-
bytes,
24-
PathLike[str],
25-
PathLike[bytes], # stable
26-
]
21+
StrOrBytesPath: TypeAlias = str | bytes | PathLike[str] | PathLike[bytes]
2722
""":class:`os.PathLike`, :class:`str` or :term:`bytes-like object`"""
2823

2924

src/libvcs/pytest_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from libvcs.sync.svn import SvnSync
2020

2121
if t.TYPE_CHECKING:
22-
from typing_extensions import TypeAlias
22+
from typing import TypeAlias
2323

2424
from libvcs._internal.run import _ENV
2525

@@ -270,7 +270,7 @@ def unique_repo_name(remote_repos_path: pathlib.Path, max_retries: int = 15) ->
270270
return remote_repo_name
271271

272272

273-
InitCmdArgs: TypeAlias = t.Optional[list[str]]
273+
InitCmdArgs: TypeAlias = list[str] | None
274274

275275

276276
class CreateRepoPostInitFn(t.Protocol):

src/libvcs/sync/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#: Default VCS systems by string (in :data:`DEFAULT_VCS_CLASS_MAP`)
1010
DEFAULT_VCS_LITERAL = t.Literal["git", "hg", "svn"]
1111
#: Union of VCS Classes
12-
DEFAULT_VCS_CLASS_UNION = type[t.Union[GitSync, HgSync, SvnSync]]
12+
DEFAULT_VCS_CLASS_UNION = type[GitSync | HgSync | SvnSync]
1313
#: ``str`` -> ``class`` Map. ``DEFAULT_VCS_CLASS_MAP['git']`` ->
1414
#: :class:`~libvcs.sync.git.GitSync`
1515
DEFAULT_VCS_CLASS_MAP: dict[DEFAULT_VCS_LITERAL, DEFAULT_VCS_CLASS_UNION] = {

src/libvcs/url/registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from libvcs._internal.module_loading import import_string
88

99
if t.TYPE_CHECKING:
10-
from typing_extensions import TypeAlias
10+
from typing import TypeAlias
1111

1212
from .base import URLProtocol
1313

14-
ParserLazyMap: TypeAlias = dict[str, t.Union[type[URLProtocol], str]]
14+
ParserLazyMap: TypeAlias = dict[str, type[URLProtocol] | str]
1515
ParserMap: TypeAlias = dict[str, type[URLProtocol]]
1616

1717
DEFAULT_PARSERS: ParserLazyMap = {

tests/url/test_registry.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313

1414
if t.TYPE_CHECKING:
1515
from collections.abc import Callable
16-
17-
from typing_extensions import TypeAlias
16+
from typing import TypeAlias
1817

1918
ParserMatchLazy: TypeAlias = Callable[[str], registry.ParserMatch]
20-
DetectVCSFixtureExpectedMatch: TypeAlias = t.Union[
21-
registry.ParserMatch,
22-
ParserMatchLazy,
23-
]
19+
DetectVCSFixtureExpectedMatch: TypeAlias = registry.ParserMatch | ParserMatchLazy
2420

2521

2622
class DetectVCSFixture(t.NamedTuple):

0 commit comments

Comments
 (0)