From 5cc97c6ab4746589fac78d84a7d5341c20f70cd1 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:49:32 +0200 Subject: [PATCH 1/2] STY: Apply ruff/flake8-pyi rule PYI034 PYI034 `__enter__` methods usually return `self` at runtime --- nibabel/openers.py | 3 ++- tox.ini | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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/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 From df862cce6f9c90536aa0b44337822d64ce792326 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:41:32 +0200 Subject: [PATCH 2/2] STY: Enforce ruff/flake8-pyi rules (PYI) --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) 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",