1+ from __future__ import annotations
12import threading
23import math
3- from typing import Callable , Dict , Iterable , List , Optional , Union
4+ from typing import Callable , Dict , Iterable , List , Optional , Union , TYPE_CHECKING
45try :
56 from collections .abc import Mapping
67except ImportError :
78 from collections import Mapping
89import logging
910import binascii
1011
12+ if TYPE_CHECKING :
13+ from ..network import Network
14+
1115from ..sdo import SdoAbortedError
1216from .. import objectdictionary
1317from .. import variable
@@ -26,14 +30,14 @@ class PdoBase(Mapping):
2630 """
2731
2832 def __init__ (self , node ):
29- self .network = None
33+ self .network : Optional [ Network ] = None
3034 self .map = None # instance of Maps
3135 self .node = node
3236
3337 def __iter__ (self ):
3438 return iter (self .map )
3539
36- def __getitem__ (self , key ):
40+ def __getitem__ (self , key ) -> PdoBase :
3741 if isinstance (key , int ) and (0x1A00 <= key <= 0x1BFF or # By TPDO ID (512)
3842 0x1600 <= key <= 0x17FF or # By RPDO ID (512)
3943 0 < key <= 512 ): # By PDO Index
@@ -160,7 +164,7 @@ def __len__(self) -> int:
160164class Map (object ):
161165 """One message which can have up to 8 bytes of variables mapped."""
162166
163- def __init__ (self , pdo_node , com_record , map_array ):
167+ def __init__ (self , pdo_node : PdoBase , com_record , map_array ):
164168 self .pdo_node = pdo_node
165169 self .com_record = com_record
166170 self .map_array = map_array
0 commit comments