From 69bb12eaaa73a6b9cb0b784f56cfebdc79eb6bd5 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Fri, 13 Feb 2026 15:16:16 +0200 Subject: [PATCH] fix(typing): add None to exc_type in __exit__ --- pytools/__init__.py | 8 ++++---- pytools/codegen.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pytools/__init__.py b/pytools/__init__.py index 28c25917..1e3c05ef 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -2285,7 +2285,7 @@ def __enter__(self) -> None: self.draw() def __exit__(self, - exc_type: type[BaseException], + exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None) -> None: self.finished() @@ -2515,7 +2515,7 @@ def __enter__(self) -> None: sys.setrecursionlimit(new_limit) def __exit__(self, - exc_type: type[BaseException], + exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None) -> None: # Deep recursion can produce deeply nested data structures @@ -2678,7 +2678,7 @@ def __enter__(self) -> Self: return self def __exit__(self, - exc_type: type[BaseException], + exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None) -> None: self.done() @@ -2841,7 +2841,7 @@ def __enter__(self): pass def __exit__(self, - exc_type: type[BaseException], + exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None) -> None: self.done() diff --git a/pytools/codegen.py b/pytools/codegen.py index 622b4c36..7d962ace 100644 --- a/pytools/codegen.py +++ b/pytools/codegen.py @@ -115,7 +115,7 @@ def __enter__(self) -> None: self.generator.indent() def __exit__(self, - exc_type: type[BaseException], + exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None) -> None: self.generator.dedent()