Skip to content

Commit 9008ed0

Browse files
committed
refactor(mypy): Adopt Python 3.10 typing idioms
- replace remaining Optional/Union patterns with PEP 604 unions aligned to the new baseline - remove outdated version blocks for Python 3.10 (now minimum) - add explicit strict=False to zip-based operations to satisfy Ruff B905 uv run ruff check . --fix --show-fixes uv run ruff format . uv run mypy uv run py.test
1 parent 5ab8bf5 commit 9008ed0

File tree

7 files changed

+9
-10
lines changed

7 files changed

+9
-10
lines changed

src/libvcs/_internal/query_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def __eq__(
489489
return False
490490

491491
if len(self) == len(data):
492-
for a, b in zip(self, data):
492+
for a, b in zip(self, data, strict=False):
493493
if isinstance(a, Mapping):
494494
a_keys = a.keys()
495495
if a.keys == b.keys():

src/libvcs/_internal/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __call__(self, output: str, timestamp: datetime.datetime) -> None:
100100
else:
101101
_ENV: TypeAlias = Mapping[bytes, StrPath] | Mapping[str, StrPath]
102102

103-
_CMD = t.Union[StrPath, Sequence[StrPath]]
103+
_CMD = StrPath | Sequence[StrPath]
104104
_FILE: TypeAlias = int | t.IO[t.Any] | None
105105

106106

src/libvcs/_internal/subprocess.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ class SubprocessCommand(SkipDefaultFieldsReprMixin):
188188
start_new_session: bool = False
189189
pass_fds: t.Any = ()
190190
umask: int = -1
191-
if sys.version_info >= (3, 10):
192-
pipesize: int = -1
191+
pipesize: int = -1
193192
user: str | None = None
194193
group: str | None = None
195194
extra_groups: list[str] | None = None

src/libvcs/cmd/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from libvcs._internal.run import ProgressCallbackProtocol, run
1212
from libvcs._internal.types import StrOrBytesPath, StrPath
1313

14-
_CMD = t.Union[StrOrBytesPath, Sequence[StrOrBytesPath]]
14+
_CMD = StrOrBytesPath | Sequence[StrOrBytesPath]
1515

1616

1717
class Git:

src/libvcs/cmd/hg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from libvcs._internal.run import ProgressCallbackProtocol, run
2020
from libvcs._internal.types import StrOrBytesPath, StrPath
2121

22-
_CMD = t.Union[StrOrBytesPath, Sequence[StrOrBytesPath]]
22+
_CMD = StrOrBytesPath | Sequence[StrOrBytesPath]
2323

2424

2525
class HgColorType(enum.Enum):

src/libvcs/cmd/svn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
from libvcs._internal.run import ProgressCallbackProtocol, run
1919
from libvcs._internal.types import StrOrBytesPath, StrPath
2020

21-
_CMD = t.Union[StrOrBytesPath, Sequence[StrOrBytesPath]]
21+
_CMD = StrOrBytesPath | Sequence[StrOrBytesPath]
2222

23-
DepthLiteral = t.Union[t.Literal["infinity", "empty", "files", "immediates"], None]
24-
RevisionLiteral = t.Union[t.Literal["HEAD", "BASE", "COMMITTED", "PREV"], None]
23+
DepthLiteral = t.Literal["infinity", "empty", "files", "immediates"] | None
24+
RevisionLiteral = t.Literal["HEAD", "BASE", "COMMITTED", "PREV"] | None
2525

2626

2727
class SvnPropsetValueOrValuePathRequired(exc.LibVCSException, TypeError):

src/libvcs/sync/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class GitRemote:
8787

8888

8989
GitSyncRemoteDict = dict[str, GitRemote]
90-
GitRemotesArgs = t.Union[None, GitSyncRemoteDict, dict[str, str]]
90+
GitRemotesArgs = None | GitSyncRemoteDict | dict[str, str]
9191

9292

9393
@dataclasses.dataclass

0 commit comments

Comments
 (0)