mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
fix: use Self return type for SCMContext.__enter__ and __call__
Return self directly in __enter__ instead of the @contextmanager's __enter__() return value. Also update __call__ to return Iterator[Self]. They're semantically identical (the contextmanager yields self), but this satisfies both ruff PYI034 and mypy. https://claude.ai/code/session_01M18n2k6KLenwMRANgSFMXc
This commit is contained in:
@@ -98,7 +98,7 @@ class SCMContext:
|
|||||||
@contextmanager
|
@contextmanager
|
||||||
def __call__(
|
def __call__(
|
||||||
self, autostage: Optional[bool] = None, quiet: Optional[bool] = None
|
self, autostage: Optional[bool] = None, quiet: Optional[bool] = None
|
||||||
) -> Iterator["SCMContext"]:
|
) -> Iterator["Self"]:
|
||||||
try:
|
try:
|
||||||
yield self
|
yield self
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -135,7 +135,8 @@ class SCMContext:
|
|||||||
|
|
||||||
def __enter__(self) -> "Self":
|
def __enter__(self) -> "Self":
|
||||||
self._cm = self()
|
self._cm = self()
|
||||||
return self._cm.__enter__()
|
self._cm.__enter__()
|
||||||
|
return self
|
||||||
|
|
||||||
def __exit__(self, *exc_args) -> None:
|
def __exit__(self, *exc_args) -> None:
|
||||||
assert self._cm
|
assert self._cm
|
||||||
|
|||||||
Reference in New Issue
Block a user