diff mbox series

[libgpiod,12/22] bindings: python: raise exception type, not exception instance

Message ID 20240927-vfazio-mypy-v1-12-91a7c2e20884@xes-inc.com
State New
Headers show
Series bindings: python: conform to mypy and ruff linter recommendations | expand

Commit Message

Vincent Fazio Sept. 27, 2024, 6:53 p.m. UTC
This resolves a strict no-untyped-call mypy warning.

Signed-off-by: Vincent Fazio <vfazio@xes-inc.com>
---
 bindings/python/gpiod/chip.py         | 2 +-
 bindings/python/gpiod/line_request.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Bartosz Golaszewski Oct. 8, 2024, 1:23 p.m. UTC | #1
On Fri, Sep 27, 2024 at 8:57 PM Vincent Fazio <vfazio@xes-inc.com> wrote:
>
> This resolves a strict no-untyped-call mypy warning.
>
> Signed-off-by: Vincent Fazio <vfazio@xes-inc.com>
> ---

Ok, so I see this is how it's done in the standard library but why? If
an error doesn't take arguments, one should raise its type? Could you
elaborate more in the commit message?

Bart
diff mbox series

Patch

diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py
index fe7bcfe082d6e9f6220093d3fc45ff232b5d0d17..27785d63806619ff70e7c75f7dd102894d3a4ec1 100644
--- a/bindings/python/gpiod/chip.py
+++ b/bindings/python/gpiod/chip.py
@@ -89,7 +89,7 @@  class Chip:
 
     def _check_closed(self) -> None:
         if not self._chip:
-            raise ChipClosedError()
+            raise ChipClosedError
 
     def close(self) -> None:
         """
diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py
index 917020b9ec7046dd8e10158f70efb555fc87eade..a9b5105e5cc5bc5f857300ba3e0eb7528ed6ae80 100644
--- a/bindings/python/gpiod/line_request.py
+++ b/bindings/python/gpiod/line_request.py
@@ -66,7 +66,7 @@  class LineRequest:
 
     def _check_released(self) -> None:
         if not self._req:
-            raise RequestReleasedError()
+            raise RequestReleasedError
 
     def release(self) -> None:
         """