Skip to content

Commit 8948bb1

Browse files
committed
Add io.py
1 parent 33d26e8 commit 8948bb1

File tree

1 file changed

+44
-0
lines changed
  • circuitpython_typing

1 file changed

+44
-0
lines changed

circuitpython_typing/io.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
"""
6+
`circuitpython_typing.io`
7+
================================================================================
8+
9+
Type annotation definitions for IO-related objects
10+
11+
* Author(s): Alec Delaney
12+
"""
13+
14+
# Protocol was introduced in Python 3.8.
15+
try:
16+
from typing import Protocol
17+
except ImportError:
18+
from typing_extensions import Protocol
19+
20+
class ROValueIO(Protocol):
21+
"""Hardware objects, like `analogio.AnalogIn`, that have read-only
22+
``value`` properties/attributes.
23+
"""
24+
25+
@property
26+
def value(self) -> float:
27+
"""Value property, that may return an `int` or `float` depending
28+
on the specifics of the class.
29+
"""
30+
31+
class ValueIO(Protocol):
32+
"""Hardware objects, like `analogio.AnalogOut`, that have read and
33+
write ``value`` properties/attributes.
34+
"""
35+
36+
@property
37+
def value(self) -> float:
38+
"""Value property, that may return an `int` or `float` depending
39+
on the specifics of the class.
40+
"""
41+
42+
@value.setter
43+
def value(self, input_value: float, /):
44+
...

0 commit comments

Comments
 (0)