diff mbox series

[libgpiod,v2,18/23] bindings: python: tests: add type stubs for external modules

Message ID 20241114145116.2123714-19-vfazio@xes-inc.com
State New
Headers show
Series bindings: python: conform to mypy and ruff linter recommendations | expand

Commit Message

Vincent Fazio Nov. 14, 2024, 2:51 p.m. UTC
Add type stubs for the compiled external modules so that types and
methods used from the modules are accurately type checked.

Signed-off-by: Vincent Fazio <vfazio@xes-inc.com>
---
 bindings/python/tests/gpiosim/_ext.pyi  | 21 +++++++++++++++++++++
 bindings/python/tests/procname/_ext.pyi |  1 +
 2 files changed, 22 insertions(+)
 create mode 100644 bindings/python/tests/gpiosim/_ext.pyi
 create mode 100644 bindings/python/tests/procname/_ext.pyi

Comments

Bartosz Golaszewski Nov. 19, 2024, 1:42 p.m. UTC | #1
On Thu, Nov 14, 2024 at 3:51 PM Vincent Fazio <vfazio@xes-inc.com> wrote:
>
> Add type stubs for the compiled external modules so that types and
> methods used from the modules are accurately type checked.
>
> Signed-off-by: Vincent Fazio <vfazio@xes-inc.com>
> ---
>  bindings/python/tests/gpiosim/_ext.pyi  | 21 +++++++++++++++++++++
>  bindings/python/tests/procname/_ext.pyi |  1 +
>  2 files changed, 22 insertions(+)
>  create mode 100644 bindings/python/tests/gpiosim/_ext.pyi
>  create mode 100644 bindings/python/tests/procname/_ext.pyi
>
> diff --git a/bindings/python/tests/gpiosim/_ext.pyi b/bindings/python/tests/gpiosim/_ext.pyi
> new file mode 100644
> index 0000000..69d4b63
> --- /dev/null
> +++ b/bindings/python/tests/gpiosim/_ext.pyi
> @@ -0,0 +1,21 @@
> +class Chip:
> +    def __init__(self) -> None: ...
> +    def set_label(self, label: str) -> None: ...
> +    def set_num_lines(self, num_lines: int) -> None: ...
> +    def set_line_name(self, offset: int, name: str) -> None: ...
> +    def set_hog(self, offset: int, name: str, direction: int) -> None: ...
> +    def enable(self) -> None: ...
> +    def get_value(set, offset: int) -> int: ...
> +    def set_pull(set, offset: int, pull: int) -> None: ...
> +    @property
> +    def dev_path(self) -> str: ...
> +    @property
> +    def name(self) -> str: ...
> +
> +PULL_DOWN: int
> +PULL_UP: int
> +VALUE_INACTIVE: int
> +VALUE_ACTIVE: int
> +DIRECTION_INPUT: int
> +DIRECTION_OUTPUT_HIGH: int
> +DIRECTION_OUTPUT_LOW: int
> diff --git a/bindings/python/tests/procname/_ext.pyi b/bindings/python/tests/procname/_ext.pyi
> new file mode 100644
> index 0000000..fdcd8ac
> --- /dev/null
> +++ b/bindings/python/tests/procname/_ext.pyi
> @@ -0,0 +1 @@
> +def set_process_name(name: str) -> None: ...
> --
> 2.34.1
>
>

This is missing the SPDX identifiers and makes `reuse lint` complain. :(

However everything else looks awesome and I don't have other issues.
Can I just use the same SPDX tags you used in other .pyi files in this
series when applying?

Bart
Vincent Fazio Nov. 19, 2024, 1:44 p.m. UTC | #2
On Tue, Nov 19, 2024 at 7:42 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> This is missing the SPDX identifiers and makes `reuse lint` complain. :(
>

I knew I missed something :(

> However everything else looks awesome and I don't have other issues.
> Can I just use the same SPDX tags you used in other .pyi files in this
> series when applying?

Yes, please do.
diff mbox series

Patch

diff --git a/bindings/python/tests/gpiosim/_ext.pyi b/bindings/python/tests/gpiosim/_ext.pyi
new file mode 100644
index 0000000..69d4b63
--- /dev/null
+++ b/bindings/python/tests/gpiosim/_ext.pyi
@@ -0,0 +1,21 @@ 
+class Chip:
+    def __init__(self) -> None: ...
+    def set_label(self, label: str) -> None: ...
+    def set_num_lines(self, num_lines: int) -> None: ...
+    def set_line_name(self, offset: int, name: str) -> None: ...
+    def set_hog(self, offset: int, name: str, direction: int) -> None: ...
+    def enable(self) -> None: ...
+    def get_value(set, offset: int) -> int: ...
+    def set_pull(set, offset: int, pull: int) -> None: ...
+    @property
+    def dev_path(self) -> str: ...
+    @property
+    def name(self) -> str: ...
+
+PULL_DOWN: int
+PULL_UP: int
+VALUE_INACTIVE: int
+VALUE_ACTIVE: int
+DIRECTION_INPUT: int
+DIRECTION_OUTPUT_HIGH: int
+DIRECTION_OUTPUT_LOW: int
diff --git a/bindings/python/tests/procname/_ext.pyi b/bindings/python/tests/procname/_ext.pyi
new file mode 100644
index 0000000..fdcd8ac
--- /dev/null
+++ b/bindings/python/tests/procname/_ext.pyi
@@ -0,0 +1 @@ 
+def set_process_name(name: str) -> None: ...