linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [libgpiod][PATCH 00/22] bindings: python: conform to mypy and ruff linter recommendations
@ 2024-09-27 18:53 Vincent Fazio
  2024-09-27 18:53 ` [libgpiod][PATCH 01/22] bindings: python: clean up imports and exports Vincent Fazio
                   ` (22 more replies)
  0 siblings, 23 replies; 50+ messages in thread
From: Vincent Fazio @ 2024-09-27 18:53 UTC (permalink / raw)
  To: linux-gpio; +Cc: vfazio, Vincent Fazio

This patch series employs mypy [0] and ruff [1] to ensure the gpiod
library has correctly typed public interfaces, is performing proper type
checking internally, is consistently formatted in a standard code style
that targets Python 3.9 syntax, and passes a subset of linting checks.

Patches 1 and 2 remove unused imports, sort the remainder, and ensure
the publicly usable classes are available from the gpiod base module.

Patches 3 and 4 fix and add annotations to the gpiod bindings.

Patches 5-13 fix type and lint errors internal to the bindings.

Patch 14 fixes a duplicate test name identified by the linter.

Patch 15 and 16 remove unused imports, sort the remainder, and fix lint
errors related to a shadowed export.

Patches 17 and 18 fix and add annotations to the test gpiod bindings.

Patches 19-21 fix type and lint errors internal to the tests.

Patch 22 adds mypy and ruff configuration to pyproject.toml and adds
documentation to the readme so future patches can be evaluated against a
standard set of rules.

There should be no functional changes that impact existing code as part
of this series.

All unit tests continue to pass without changes and code coverage has
not changed.

After this series is applied, the public type annotations will reflect
the argument expectations of the class methods so consumers can type
check their code against the gpiod type annotations.

[0]: https://mypy.readthedocs.io/en/stable/ 
[1]: https://docs.astral.sh/ruff/ 

Signed-off-by: Vincent Fazio <vfazio@xes-inc.com>
---
Vincent Fazio (22):
      bindings: python: clean up imports and exports
      bindings: python: make internal a private submodule
      bindings: python: fix annotation of variable length tuples
      bindings: python: add missing method type annotations
      bindings: python: add type stubs for _ext
      bindings: python: annotate internal members of Chip
      bindings: python: fix Chip union-attr type errors
      bindings: python: annotate internal members of LineRequest
      bindings: python: fix LineRequest union-attr type errors
      bindings: python: convert lines to offsets in LineRequest
      bindings: python: cast return value of LineRequest.get_values
      bindings: python: raise exception type, not exception instance
      bindings: python: selectively use f-strings
      bindings: python: tests: fix duplicate test name
      bindings: python: tests: clean up imports and exports
      bindings: python: tests: make EventType private to prevent export
      bindings: python: tests: add type stubs for external modules
      bindings: python: tests: add missing type annotations
      bindings: python: tests: ignore purposeful type errors
      bindings: python: tests: annotate internal members
      bindings: python: tests: use f-strings
      bindings: python: configure and document dev dependencies

 bindings/python/README.md                          |  17 ++
 bindings/python/gpiod/__init__.py                  |  83 ++++++--
 bindings/python/gpiod/_ext.pyi                     |  93 +++++++++
 .../python/gpiod/{internal.py => _internal.py}     |   3 +-
 bindings/python/gpiod/chip.py                      |  56 ++++--
 bindings/python/gpiod/chip_info.py                 |   6 +-
 bindings/python/gpiod/edge_event.py                |   9 +-
 bindings/python/gpiod/exception.py                 |   4 +-
 bindings/python/gpiod/info_event.py                |  11 +-
 bindings/python/gpiod/line.py                      |   5 +-
 bindings/python/gpiod/line_info.py                 |  10 +-
 bindings/python/gpiod/line_request.py              |  80 +++++---
 bindings/python/gpiod/line_settings.py             |  15 +-
 bindings/python/pyproject.toml                     |  36 ++++
 bindings/python/setup.py                           |   2 +-
 bindings/python/tests/__init__.py                  |   6 +-
 bindings/python/tests/__main__.py                  |   5 +-
 bindings/python/tests/gpiosim/__init__.py          |   2 +
 bindings/python/tests/gpiosim/_ext.pyi             |  21 +++
 bindings/python/tests/gpiosim/chip.py              |   3 +-
 bindings/python/tests/helpers.py                   |   6 +-
 bindings/python/tests/procname/__init__.py         |   2 +
 bindings/python/tests/procname/_ext.pyi            |   1 +
 bindings/python/tests/tests_chip.py                | 105 ++++++-----
 bindings/python/tests/tests_chip_info.py           |  38 ++--
 bindings/python/tests/tests_edge_event.py          |  66 ++++---
 bindings/python/tests/tests_info_event.py          | 100 ++++++----
 bindings/python/tests/tests_line.py                |   5 +-
 bindings/python/tests/tests_line_info.py           |  49 +++--
 bindings/python/tests/tests_line_request.py        | 210 ++++++++++-----------
 bindings/python/tests/tests_line_settings.py       |  19 +-
 bindings/python/tests/tests_module.py              |  37 ++--
 32 files changed, 710 insertions(+), 395 deletions(-)
---
base-commit: f6c8c3321d8f30979fa593a4f6546ff3dccd2549
change-id: 20240923-vfazio-mypy-2037e7d5bdd6

Best regards,
-- 
Vincent Fazio <vfazio@xes-inc.com>

^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2024-10-09 18:24 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-27 18:53 [libgpiod][PATCH 00/22] bindings: python: conform to mypy and ruff linter recommendations Vincent Fazio
2024-09-27 18:53 ` [libgpiod][PATCH 01/22] bindings: python: clean up imports and exports Vincent Fazio
2024-10-08 11:16   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 02/22] bindings: python: make internal a private submodule Vincent Fazio
2024-10-08 11:24   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 03/22] bindings: python: fix annotation of variable length tuples Vincent Fazio
2024-10-08 13:02   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 04/22] bindings: python: add missing method type annotations Vincent Fazio
2024-10-08 13:07   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 05/22] bindings: python: add type stubs for _ext Vincent Fazio
2024-10-08 13:08   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 06/22] bindings: python: annotate internal members of Chip Vincent Fazio
2024-10-08 13:09   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 07/22] bindings: python: fix Chip union-attr type errors Vincent Fazio
2024-10-08 13:16   ` Bartosz Golaszewski
2024-10-08 14:57     ` Vincent Fazio
2024-10-08 15:46       ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 08/22] bindings: python: annotate internal members of LineRequest Vincent Fazio
2024-10-08 13:17   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 09/22] bindings: python: fix LineRequest union-attr type errors Vincent Fazio
2024-10-08 13:18   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 10/22] bindings: python: convert lines to offsets in LineRequest Vincent Fazio
2024-10-08 13:19   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 11/22] bindings: python: cast return value of LineRequest.get_values Vincent Fazio
2024-10-08 13:20   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 12/22] bindings: python: raise exception type, not exception instance Vincent Fazio
2024-10-08 13:23   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 13/22] bindings: python: selectively use f-strings Vincent Fazio
2024-10-08 13:24   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 14/22] bindings: python: tests: fix duplicate test name Vincent Fazio
2024-10-08 13:25   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 15/22] bindings: python: tests: clean up imports and exports Vincent Fazio
2024-10-08 13:27   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 16/22] bindings: python: tests: make EventType private to prevent export Vincent Fazio
2024-10-08 13:29   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 17/22] bindings: python: tests: add type stubs for external modules Vincent Fazio
2024-10-08 13:30   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 18/22] bindings: python: tests: add missing type annotations Vincent Fazio
2024-10-08 13:32   ` Bartosz Golaszewski
2024-10-09 16:41     ` Vincent Fazio
2024-10-09 18:24       ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 19/22] bindings: python: tests: ignore purposeful type errors Vincent Fazio
2024-10-08 13:33   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 20/22] bindings: python: tests: annotate internal members Vincent Fazio
2024-10-08 13:34   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 21/22] bindings: python: tests: use f-strings Vincent Fazio
2024-10-08 13:35   ` Bartosz Golaszewski
2024-09-27 18:53 ` [libgpiod][PATCH 22/22] bindings: python: configure and document dev dependencies Vincent Fazio
2024-10-08 13:35   ` Bartosz Golaszewski
2024-10-08 13:37 ` [libgpiod][PATCH 00/22] bindings: python: conform to mypy and ruff linter recommendations Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).