bindings: python: disable UP045 linter check
PATCH 1/1 bindings: python: disable UP045 linter check
Linter check UP045 [0] was recently stabilized in ruff 0.12 [1].
UP045 suggests using the X | Y syntax for files that perform:
from __future__ import annotations
This import drives the Python interpreter to store type annotations as strings and defers their evaluation [2] making the new syntax "safe".
See also [3] for a brief history.
For now, disable the UP045 linter warnings like we do UP007 [4] for the sake of consistency within the bindings so there is no mixed usage of Union[X, Y] and Optional[X] vs X | Y until the bindings minimally target Python 3.10 and can move to the latter syntax.
[0]: https://docs.astral.sh/ruff/rules/non-pep604-annotation-optional/
[1]: https://github.com/astral-sh/ruff/commit/de4fc5b171d8b4a9dfd44ef9b551f1257661ab60
[2]: https://peps.python.org/pep-0563/#implementation
[3]: https://peps.python.org/pep-0649/#a-history-of-annotations
[4]: https://docs.astral.sh/ruff/rules/non-pep604-annotation-union/
--- bindings/python/pyproject.toml | 1 + 1 file changed, 1 insertion(+)
bindings/python/pyproject.toml +1 -0
@@ -73,6 +73,7 @@ ignore=[ "E501", # Ignore new Union (|) syntax until we require 3.10+ "UP007", + "UP045", ] [tool.ruff.lint.per-file-ignores]
Signature · 1 line
2.43.0
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 10 lines · Vincent Fazio
Linter check UP045 [0] was recently stabilized in ruff 0.12 [1].
UP045 suggests using the
X | Ysyntax for files that perform:from
__future__import annotationsThis import drives the Python interpreter to store type annotations as strings and defers their evaluation [2] making the new syntax "safe".
[...]
Applied, thanks!
[1/1] bindings: python: disable UP045 linter check
https://git.kernel.org/brgl/libgpiod/c/4db87075549ebe3fa6d4d381186e30097f327fc7
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>