Skip to content

Commit 39e0536

Browse files
committed
fix mypy and ruff errors
1 parent 94ee8fc commit 39e0536

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

dvc/repo/scm_context.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from dvc.utils.collections import ensure_list
1111

1212
if TYPE_CHECKING:
13+
from typing_extensions import Self
14+
1315
from dvc.repo import Repo
1416
from dvc.scm import Base
1517

@@ -96,7 +98,7 @@ def ignore_remove(self, path: str) -> None:
9698
@contextmanager
9799
def __call__(
98100
self, autostage: Optional[bool] = None, quiet: Optional[bool] = None
99-
) -> Iterator["SCMContext"]:
101+
) -> Iterator["Self"]:
100102
try:
101103
yield self
102104
except Exception:
@@ -131,9 +133,10 @@ def __call__(
131133

132134
self.files_to_track = set()
133135

134-
def __enter__(self) -> "SCMContext":
136+
def __enter__(self) -> "Self":
135137
self._cm = self()
136-
return self._cm.__enter__()
138+
self._cm.__enter__()
139+
return self
137140

138141
def __exit__(self, *exc_args) -> None:
139142
assert self._cm

dvc/testing/path_info.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pathlib
33
import posixpath
44
import sys
5-
from typing import Callable, ClassVar
5+
from typing import Callable, ClassVar, Union
66
from urllib.parse import urlparse
77

88
from dvc.utils import relpath
@@ -79,15 +79,17 @@ def isin(self, other):
7979
and self._cparts[:n] == other._cparts # type: ignore[attr-defined]
8080
)
8181

82-
def relative_to(self, other, *args, **kwargs):
82+
def relative_to(
83+
self, *other: Union[str, "os.PathLike[str]"], **kwargs
84+
) -> "PathInfo":
8385
# pathlib relative_to raises exception when one path is not a direct
8486
# descendant of the other when os.path.relpath would return abspath.
8587
# For DVC PathInfo we only need the relpath behavior.
8688
# See: https://bugs.python.org/issue40358
8789
try:
88-
path = super().relative_to(other, *args, **kwargs)
90+
path = super().relative_to(*other, **kwargs)
8991
except ValueError:
90-
path = relpath(self, other)
92+
path = relpath(self, other[0])
9193
return self.__class__(path)
9294

9395

tests/unit/command/test_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_help(caplog, capsys, command_tuples):
4747
out, err = capsys.readouterr()
4848

4949
# validate metavars are all in lowercase
50-
usage = "\n".join(takewhile(lambda o: bool(o), out.splitlines()))
50+
usage = "\n".join(takewhile(bool, out.splitlines()))
5151

5252
message = (
5353
"metavars not lowercased, you are likely missing formatter_class=XXX "

0 commit comments

Comments
 (0)