diff --git a/nibabel/openers.py b/nibabel/openers.py index 9a306d4e4..35b10c20a 100644 --- a/nibabel/openers.py +++ b/nibabel/openers.py @@ -22,6 +22,7 @@ from types import TracebackType from _typeshed import WriteableBuffer + from typing_extensions import Self ModeRT = ty.Literal['r', 'rt'] ModeRB = ty.Literal['rb'] @@ -246,7 +247,7 @@ def close_if_mine(self) -> None: if self.me_opened: self.close() - def __enter__(self) -> Opener: + def __enter__(self) -> Self: return self def __exit__( diff --git a/pyproject.toml b/pyproject.toml index fa3f88116..0dd49c847 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -123,6 +123,7 @@ select = [ "I", "PIE", "PLE", + "PYI", "Q", "RSE", "TCH", @@ -143,6 +144,7 @@ ignore = [ "C408", "C416", "PIE790", + "PYI024", # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules "W191", "E111", diff --git a/tox.ini b/tox.ini index 5df35c8d3..675526f94 100644 --- a/tox.ini +++ b/tox.ini @@ -181,6 +181,7 @@ deps = numpy pyzstd importlib_resources + typing_extensions skip_install = true commands = mypy nibabel