Skip to content

Commit 080462e

Browse files
committed
Working around missing _typeshed package
1 parent 054823d commit 080462e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

adafruit_avrprog.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,22 @@
3333
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_AVRprog.git"
3434

3535
try:
36-
from typing import Any, Dict, Optional, Tuple
36+
from os import PathLike
37+
from typing import Any, Dict, Optional, Tuple, TypeAlias
38+
39+
# Technically this type should come from: from _typeshed import FileDescriptorOrPath
40+
# Unfortunately _typeshed is only in the standard library in newer releases of Python, e.g. 3.11
41+
# Thus have to define a placeholder
42+
FileDescriptorOrPath: TypeAlias = (
43+
int | str | bytes | PathLike[str] | PathLike[bytes]
44+
)
45+
from io import TextIOWrapper
3746

3847
except ImportError:
3948
pass
4049

41-
from io import TextIOWrapper
4250
from math import floor
4351

44-
from _typeshed import FileDescriptorOrPath
4552
from busio import SPI
4653
from digitalio import DigitalInOut, Direction
4754

0 commit comments

Comments
 (0)