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:
Claude
2026-02-11 08:15:06 +00:00
parent c541954a80
commit 291bb79836
+3 -2
View File
@@ -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