From 319b857354cdb485358c0221d4d4722993cd7e59 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Wed, 20 Apr 2022 23:09:22 -0400 Subject: [PATCH 1/3] Correct docstring mislabel in led.py --- circuitpython_typing/led.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/circuitpython_typing/led.py b/circuitpython_typing/led.py index 741996b..5943ea0 100644 --- a/circuitpython_typing/led.py +++ b/circuitpython_typing/led.py @@ -6,8 +6,7 @@ `circuitpython_typing.led` ================================================================================ -Type annotation definitions for device drivers. Used for where LEDs are -type annotated. +Type annotation definitions for LEDs. * Author(s): Alec Delaney """ From 40ce66eef89df4d699b2a47228887567a77bbc70 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Wed, 20 Apr 2022 23:09:46 -0400 Subject: [PATCH 2/3] Add pwmio.py for PWMOut Protocol --- circuitpython_typing/pwmio.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 circuitpython_typing/pwmio.py diff --git a/circuitpython_typing/pwmio.py b/circuitpython_typing/pwmio.py new file mode 100644 index 0000000..ca68194 --- /dev/null +++ b/circuitpython_typing/pwmio.py @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney +# +# SPDX-License-Identifier: MIT + +""" +`circuitpython_typing.pwmio` +================================================================================ + +Type annotation definitions for PWMOut where Blinka doesn't otherwise define it. + +* Author(s): Alec Delaney +""" + +# # Protocol was introduced in Python 3.8. +try: + from typing import Union, Tuple, Protocol +except ImportError: + from typing_extensions import Protocol + +class PWMOut(Protocol): + """Protocol that implements, at the bare minimum, the `duty_cycle` property""" + + @property + def duty_cycle(self) -> int: + """The duty cycle as a ratio using 16-bits""" + ... + + @duty_cycle.setter + def duty_cycle(self, duty_cycle: int) -> None: + ... From 7b31522a2ff12c031ed20867d06a76152bf5aab0 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Wed, 20 Apr 2022 23:20:34 -0400 Subject: [PATCH 3/3] Remove unused imports --- circuitpython_typing/pwmio.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/circuitpython_typing/pwmio.py b/circuitpython_typing/pwmio.py index ca68194..8eed314 100644 --- a/circuitpython_typing/pwmio.py +++ b/circuitpython_typing/pwmio.py @@ -13,10 +13,11 @@ # # Protocol was introduced in Python 3.8. try: - from typing import Union, Tuple, Protocol + from typing import Protocol except ImportError: from typing_extensions import Protocol + class PWMOut(Protocol): """Protocol that implements, at the bare minimum, the `duty_cycle` property"""