Skip to content

Commit

Permalink
Use typing_extensions.TypedDict on python < 3.12 for pydantic support
Browse files Browse the repository at this point in the history
  • Loading branch information
NickCao authored and hardbyte committed Oct 8, 2024
1 parent c5c18dc commit 950e4b4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions can/typechecking.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
else:
from typing_extensions import TypeAlias

if sys.version_info >= (3, 12):
from typing import TypedDict
else:
from typing_extensions import TypedDict


if typing.TYPE_CHECKING:
import os


class CanFilter(typing.TypedDict):
class CanFilter(TypedDict):
can_id: int
can_mask: int


class CanFilterExtended(typing.TypedDict):
class CanFilterExtended(TypedDict):
can_id: int
can_mask: int
extended: bool
Expand Down Expand Up @@ -56,15 +61,15 @@ class CanFilterExtended(typing.TypedDict):
]


class AutoDetectedConfig(typing.TypedDict):
class AutoDetectedConfig(TypedDict):
interface: str
channel: Channel


ReadableBytesLike = typing.Union[bytes, bytearray, memoryview]


class BitTimingDict(typing.TypedDict):
class BitTimingDict(TypedDict):
f_clock: int
brp: int
tseg1: int
Expand All @@ -73,7 +78,7 @@ class BitTimingDict(typing.TypedDict):
nof_samples: int


class BitTimingFdDict(typing.TypedDict):
class BitTimingFdDict(TypedDict):
f_clock: int
nom_brp: int
nom_tseg1: int
Expand Down

0 comments on commit 950e4b4

Please sign in to comment.