Message ID | 20240927-vfazio-mypy-v1-2-91a7c2e20884@xes-inc.com |
---|---|
State | New |
Headers | show |
Series | bindings: python: conform to mypy and ruff linter recommendations | expand |
On Fri, Sep 27, 2024 at 9:05 PM Vincent Fazio <vfazio@xes-inc.com> wrote: > > The internal submodule shouldn't be exposed as part of the public > interface, so mark it private following PEP 8 convention [0]. > > Also, add a type annotation to `sec` for its possible types. > > [0]: https://peps.python.org/pep-0008/#public-and-internal-interfaces > Signed-off-by: Vincent Fazio <vfazio@xes-inc.com> > --- > bindings/python/gpiod/{internal.py => _internal.py} | 1 + > bindings/python/gpiod/chip.py | 2 +- > bindings/python/gpiod/line_request.py | 2 +- > 3 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/bindings/python/gpiod/internal.py b/bindings/python/gpiod/_internal.py > similarity index 94% > rename from bindings/python/gpiod/internal.py > rename to bindings/python/gpiod/_internal.py > index d1e95e4ade3146f596643d52207b367e332e6f7e..c9b5d2850389d5314a12bf6d151774a96469a085 100644 > --- a/bindings/python/gpiod/internal.py > +++ b/bindings/python/gpiod/_internal.py > @@ -9,6 +9,7 @@ __all__ = ["poll_fd"] > > > def poll_fd(fd: int, timeout: Optional[Union[timedelta, float]] = None) -> bool: > + sec: Union[float, None] This has nothing to do with marking internal as private. Can this be a separate commit? Otherwise, looks good. Bart > if isinstance(timeout, timedelta): > sec = timeout.total_seconds() > else: > diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py > index 257a31eba8d19634fd14e3b1d33a1345a0363946..1a1bba4d6dd9e840a60394f1b74903f6ad15a0f4 100644 > --- a/bindings/python/gpiod/chip.py > +++ b/bindings/python/gpiod/chip.py > @@ -7,10 +7,10 @@ from errno import ENOENT > from typing import Optional, Union > > from . import _ext > +from ._internal import poll_fd > from .chip_info import ChipInfo > from .exception import ChipClosedError > from .info_event import InfoEvent > -from .internal import poll_fd > from .line import Value > from .line_info import LineInfo > from .line_request import LineRequest > diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py > index e48830450dcb5b7fa6c7983a0fe074cd9bd32ab7..154174872e488fa478b27f5e83d65e6040aca367 100644 > --- a/bindings/python/gpiod/line_request.py > +++ b/bindings/python/gpiod/line_request.py > @@ -6,9 +6,9 @@ from datetime import timedelta > from typing import Optional, Union > > from . import _ext > +from ._internal import poll_fd > from .edge_event import EdgeEvent > from .exception import RequestReleasedError > -from .internal import poll_fd > from .line import Value > from .line_settings import LineSettings, _line_settings_to_ext > > > -- > 2.34.1 >
diff --git a/bindings/python/gpiod/internal.py b/bindings/python/gpiod/_internal.py similarity index 94% rename from bindings/python/gpiod/internal.py rename to bindings/python/gpiod/_internal.py index d1e95e4ade3146f596643d52207b367e332e6f7e..c9b5d2850389d5314a12bf6d151774a96469a085 100644 --- a/bindings/python/gpiod/internal.py +++ b/bindings/python/gpiod/_internal.py @@ -9,6 +9,7 @@ __all__ = ["poll_fd"] def poll_fd(fd: int, timeout: Optional[Union[timedelta, float]] = None) -> bool: + sec: Union[float, None] if isinstance(timeout, timedelta): sec = timeout.total_seconds() else: diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py index 257a31eba8d19634fd14e3b1d33a1345a0363946..1a1bba4d6dd9e840a60394f1b74903f6ad15a0f4 100644 --- a/bindings/python/gpiod/chip.py +++ b/bindings/python/gpiod/chip.py @@ -7,10 +7,10 @@ from errno import ENOENT from typing import Optional, Union from . import _ext +from ._internal import poll_fd from .chip_info import ChipInfo from .exception import ChipClosedError from .info_event import InfoEvent -from .internal import poll_fd from .line import Value from .line_info import LineInfo from .line_request import LineRequest diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py index e48830450dcb5b7fa6c7983a0fe074cd9bd32ab7..154174872e488fa478b27f5e83d65e6040aca367 100644 --- a/bindings/python/gpiod/line_request.py +++ b/bindings/python/gpiod/line_request.py @@ -6,9 +6,9 @@ from datetime import timedelta from typing import Optional, Union from . import _ext +from ._internal import poll_fd from .edge_event import EdgeEvent from .exception import RequestReleasedError -from .internal import poll_fd from .line import Value from .line_settings import LineSettings, _line_settings_to_ext
The internal submodule shouldn't be exposed as part of the public interface, so mark it private following PEP 8 convention [0]. Also, add a type annotation to `sec` for its possible types. [0]: https://peps.python.org/pep-0008/#public-and-internal-interfaces Signed-off-by: Vincent Fazio <vfazio@xes-inc.com> --- bindings/python/gpiod/{internal.py => _internal.py} | 1 + bindings/python/gpiod/chip.py | 2 +- bindings/python/gpiod/line_request.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-)