From 291bb798362a6ac288d18f8cce523c4f7a27caf7 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Feb 2026 08:02:04 +0000 Subject: [PATCH] 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 --- dvc/repo/scm_context.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dvc/repo/scm_context.py b/dvc/repo/scm_context.py index 61b8e8580..3103f4f6a 100644 --- a/dvc/repo/scm_context.py +++ b/dvc/repo/scm_context.py @@ -98,7 +98,7 @@ class SCMContext: @contextmanager def __call__( self, autostage: Optional[bool] = None, quiet: Optional[bool] = None - ) -> Iterator["SCMContext"]: + ) -> Iterator["Self"]: try: yield self except Exception: @@ -135,7 +135,8 @@ class SCMContext: def __enter__(self) -> "Self": self._cm = self() - return self._cm.__enter__() + self._cm.__enter__() + return self def __exit__(self, *exc_args) -> None: assert self._cm