odxtools 9.7.0__py3-none-any.whl → 10.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. odxtools/additionalaudience.py +3 -3
  2. odxtools/admindata.py +8 -8
  3. odxtools/audience.py +10 -10
  4. odxtools/basecomparam.py +5 -5
  5. odxtools/basevariantpattern.py +4 -5
  6. odxtools/basicstructure.py +8 -8
  7. odxtools/cli/_print_utils.py +35 -23
  8. odxtools/cli/browse.py +9 -9
  9. odxtools/cli/compare.py +24 -24
  10. odxtools/cli/decode.py +3 -4
  11. odxtools/cli/find.py +4 -5
  12. odxtools/cli/list.py +7 -7
  13. odxtools/cli/main.py +2 -2
  14. odxtools/cli/snoop.py +3 -3
  15. odxtools/codec.py +3 -3
  16. odxtools/commrelation.py +11 -11
  17. odxtools/companydata.py +5 -5
  18. odxtools/companydocinfo.py +8 -8
  19. odxtools/companyrevisioninfo.py +5 -5
  20. odxtools/companyspecificinfo.py +5 -5
  21. odxtools/comparam.py +3 -3
  22. odxtools/comparaminstance.py +10 -10
  23. odxtools/comparamspec.py +3 -3
  24. odxtools/comparamsubset.py +5 -5
  25. odxtools/complexcomparam.py +7 -7
  26. odxtools/compositecodec.py +11 -11
  27. odxtools/compumethods/compucodecompumethod.py +4 -4
  28. odxtools/compumethods/compuconst.py +4 -5
  29. odxtools/compumethods/compudefaultvalue.py +1 -2
  30. odxtools/compumethods/compuinternaltophys.py +6 -6
  31. odxtools/compumethods/compumethod.py +5 -5
  32. odxtools/compumethods/compuphystointernal.py +6 -6
  33. odxtools/compumethods/compurationalcoeffs.py +4 -4
  34. odxtools/compumethods/compuscale.py +9 -10
  35. odxtools/compumethods/createanycompumethod.py +1 -2
  36. odxtools/compumethods/identicalcompumethod.py +1 -2
  37. odxtools/compumethods/limit.py +12 -12
  38. odxtools/compumethods/linearcompumethod.py +2 -2
  39. odxtools/compumethods/linearsegment.py +14 -15
  40. odxtools/compumethods/ratfunccompumethod.py +3 -3
  41. odxtools/compumethods/ratfuncsegment.py +7 -8
  42. odxtools/compumethods/scalelinearcompumethod.py +7 -7
  43. odxtools/compumethods/scaleratfunccompumethod.py +4 -4
  44. odxtools/compumethods/tabintpcompumethod.py +15 -18
  45. odxtools/compumethods/texttablecompumethod.py +3 -3
  46. odxtools/createanycomparam.py +2 -4
  47. odxtools/createanydiagcodedtype.py +1 -2
  48. odxtools/database.py +9 -8
  49. odxtools/dataobjectproperty.py +10 -10
  50. odxtools/decodestate.py +5 -5
  51. odxtools/description.py +5 -5
  52. odxtools/determinenumberofitems.py +4 -4
  53. odxtools/diagcodedtype.py +7 -7
  54. odxtools/diagcomm.py +17 -17
  55. odxtools/diagdatadictionaryspec.py +6 -6
  56. odxtools/diaglayercontainer.py +4 -4
  57. odxtools/diaglayers/basevariant.py +10 -9
  58. odxtools/diaglayers/basevariantraw.py +9 -9
  59. odxtools/diaglayers/diaglayer.py +20 -19
  60. odxtools/diaglayers/diaglayerraw.py +10 -10
  61. odxtools/diaglayers/diaglayertype.py +1 -2
  62. odxtools/diaglayers/ecushareddata.py +4 -4
  63. odxtools/diaglayers/ecushareddataraw.py +6 -6
  64. odxtools/diaglayers/ecuvariant.py +11 -10
  65. odxtools/diaglayers/ecuvariantraw.py +9 -9
  66. odxtools/diaglayers/functionalgroup.py +8 -7
  67. odxtools/diaglayers/functionalgroupraw.py +7 -7
  68. odxtools/diaglayers/hierarchyelement.py +43 -49
  69. odxtools/diaglayers/hierarchyelementraw.py +4 -4
  70. odxtools/diaglayers/protocol.py +4 -4
  71. odxtools/diaglayers/protocolraw.py +6 -6
  72. odxtools/diagnostictroublecode.py +8 -8
  73. odxtools/diagservice.py +18 -18
  74. odxtools/diagvariable.py +14 -14
  75. odxtools/docrevision.py +11 -11
  76. odxtools/dopbase.py +6 -6
  77. odxtools/dtcconnector.py +3 -3
  78. odxtools/dtcdop.py +13 -9
  79. odxtools/dynamicendmarkerfield.py +5 -4
  80. odxtools/dynamiclengthfield.py +5 -4
  81. odxtools/dyndefinedspec.py +5 -5
  82. odxtools/dynenddopref.py +5 -5
  83. odxtools/dyniddefmodeinfo.py +13 -13
  84. odxtools/ecuvariantpattern.py +4 -5
  85. odxtools/element.py +5 -6
  86. odxtools/encodestate.py +11 -11
  87. odxtools/encoding.py +2 -3
  88. odxtools/endofpdufield.py +6 -6
  89. odxtools/envdataconnector.py +3 -3
  90. odxtools/environmentdata.py +3 -4
  91. odxtools/environmentdatadescription.py +11 -11
  92. odxtools/exceptions.py +5 -5
  93. odxtools/externalaccessmethod.py +1 -2
  94. odxtools/externaldoc.py +4 -4
  95. odxtools/field.py +9 -10
  96. odxtools/functionalclass.py +4 -4
  97. odxtools/inputparam.py +6 -6
  98. odxtools/internalconstr.py +4 -5
  99. odxtools/isotp_state_machine.py +12 -11
  100. odxtools/leadinglengthinfotype.py +2 -3
  101. odxtools/library.py +5 -5
  102. odxtools/linkeddtcdop.py +4 -4
  103. odxtools/loadfile.py +5 -6
  104. odxtools/matchingbasevariantparameter.py +2 -3
  105. odxtools/matchingparameter.py +7 -7
  106. odxtools/minmaxlengthtype.py +4 -4
  107. odxtools/modification.py +4 -4
  108. odxtools/multiplexer.py +11 -11
  109. odxtools/multiplexercase.py +6 -6
  110. odxtools/multiplexerdefaultcase.py +6 -6
  111. odxtools/multiplexerswitchkey.py +4 -4
  112. odxtools/nameditemlist.py +14 -14
  113. odxtools/negoutputparam.py +3 -3
  114. odxtools/obd.py +1 -2
  115. odxtools/odxcategory.py +6 -6
  116. odxtools/odxlink.py +19 -20
  117. odxtools/odxtypes.py +21 -18
  118. odxtools/outputparam.py +4 -4
  119. odxtools/parameterinfo.py +1 -1
  120. odxtools/parameters/codedconstparameter.py +5 -5
  121. odxtools/parameters/createanyparameter.py +1 -2
  122. odxtools/parameters/dynamicparameter.py +2 -3
  123. odxtools/parameters/lengthkeyparameter.py +5 -5
  124. odxtools/parameters/matchingrequestparameter.py +3 -4
  125. odxtools/parameters/nrcconstparameter.py +7 -7
  126. odxtools/parameters/parameter.py +11 -11
  127. odxtools/parameters/parameterwithdop.py +9 -9
  128. odxtools/parameters/physicalconstantparameter.py +4 -4
  129. odxtools/parameters/reservedparameter.py +3 -4
  130. odxtools/parameters/systemparameter.py +2 -3
  131. odxtools/parameters/tableentryparameter.py +3 -3
  132. odxtools/parameters/tablekeyparameter.py +10 -10
  133. odxtools/parameters/tablestructparameter.py +7 -7
  134. odxtools/parameters/valueparameter.py +7 -7
  135. odxtools/paramlengthinfotype.py +5 -3
  136. odxtools/parentref.py +9 -9
  137. odxtools/physicaldimension.py +11 -11
  138. odxtools/physicaltype.py +3 -4
  139. odxtools/posresponsesuppressible.py +9 -10
  140. odxtools/preconditionstateref.py +7 -7
  141. odxtools/progcode.py +6 -6
  142. odxtools/protstack.py +4 -4
  143. odxtools/relateddiagcommref.py +1 -2
  144. odxtools/relateddoc.py +6 -6
  145. odxtools/request.py +9 -9
  146. odxtools/response.py +10 -10
  147. odxtools/scaleconstr.py +3 -4
  148. odxtools/servicebinner.py +5 -5
  149. odxtools/singleecujob.py +4 -4
  150. odxtools/snrefcontext.py +2 -2
  151. odxtools/specialdata.py +5 -5
  152. odxtools/specialdatagroup.py +9 -9
  153. odxtools/specialdatagroupcaption.py +3 -3
  154. odxtools/standardlengthtype.py +10 -10
  155. odxtools/state.py +3 -3
  156. odxtools/statechart.py +4 -4
  157. odxtools/statemachine.py +4 -3
  158. odxtools/statetransition.py +4 -4
  159. odxtools/statetransitionref.py +18 -18
  160. odxtools/staticfield.py +5 -4
  161. odxtools/structure.py +2 -3
  162. odxtools/subcomponent.py +5 -5
  163. odxtools/subcomponentparamconnector.py +5 -5
  164. odxtools/subcomponentpattern.py +4 -4
  165. odxtools/swvariable.py +3 -4
  166. odxtools/table.py +14 -14
  167. odxtools/tablediagcommconnector.py +5 -5
  168. odxtools/tablerow.py +30 -30
  169. odxtools/tablerowconnector.py +3 -3
  170. odxtools/teammember.py +11 -11
  171. odxtools/text.py +2 -3
  172. odxtools/uds.py +2 -3
  173. odxtools/unit.py +9 -9
  174. odxtools/unitgroup.py +5 -5
  175. odxtools/unitspec.py +6 -6
  176. odxtools/utils.py +3 -3
  177. odxtools/variablegroup.py +2 -2
  178. odxtools/variantmatcher.py +10 -10
  179. odxtools/variantpattern.py +3 -3
  180. odxtools/version.py +2 -2
  181. odxtools/writepdxfile.py +5 -5
  182. odxtools/xdoc.py +9 -9
  183. {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/METADATA +4 -5
  184. odxtools-10.0.0.dist-info/RECORD +264 -0
  185. odxtools-9.7.0.dist-info/RECORD +0 -264
  186. {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/WHEEL +0 -0
  187. {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/entry_points.txt +0 -0
  188. {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/licenses/LICENSE +0 -0
  189. {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, cast
3
+ from typing import cast
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from ..exceptions import DecodeError, EncodeError, odxassert, odxraise, odxrequire
@@ -22,7 +22,7 @@ class TexttableCompuMethod(CompuMethod):
22
22
  """
23
23
 
24
24
  @staticmethod
25
- def compu_method_from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment], *,
25
+ def compu_method_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
26
26
  internal_type: DataType,
27
27
  physical_type: DataType) -> "TexttableCompuMethod":
28
28
  cm = CompuMethod.compu_method_from_et(
@@ -95,7 +95,7 @@ class TexttableCompuMethod(CompuMethod):
95
95
  scales = []
96
96
  if (citp := self.compu_internal_to_phys) is not None:
97
97
  scales = citp.compu_scales
98
- matching_scales: List[CompuScale] = [x for x in scales if x.applies(internal_value)]
98
+ matching_scales: list[CompuScale] = [x for x in scales if x.applies(internal_value)]
99
99
 
100
100
  if len(matching_scales) == 0:
101
101
  if self._compu_physical_default_value is None:
@@ -1,4 +1,3 @@
1
- from typing import List, Union
2
1
  from xml.etree import ElementTree
3
2
 
4
3
  from .comparam import Comparam
@@ -6,9 +5,8 @@ from .complexcomparam import ComplexComparam
6
5
  from .odxlink import OdxDocFragment
7
6
 
8
7
 
9
- def create_any_comparam_from_et(
10
- et_element: ElementTree.Element,
11
- doc_frags: List[OdxDocFragment]) -> Union[Comparam, ComplexComparam]:
8
+ def create_any_comparam_from_et(et_element: ElementTree.Element,
9
+ doc_frags: list[OdxDocFragment]) -> Comparam | ComplexComparam:
12
10
  if et_element.tag == "COMPARAM":
13
11
  return Comparam.from_et(et_element, doc_frags)
14
12
  elif et_element.tag == "COMPLEX-COMPARAM":
@@ -1,5 +1,4 @@
1
1
  # SPDX-License-Identifier: MIT
2
- from typing import List
3
2
  from xml.etree import ElementTree
4
3
 
5
4
  from .diagcodedtype import DiagCodedType
@@ -13,7 +12,7 @@ from .standardlengthtype import StandardLengthType
13
12
 
14
13
 
15
14
  def create_any_diag_coded_type_from_et(et_element: ElementTree.Element,
16
- doc_frags: List[OdxDocFragment]) -> DiagCodedType:
15
+ doc_frags: list[OdxDocFragment]) -> DiagCodedType:
17
16
  dct_type = et_element.get(f"{xsi}type")
18
17
  if dct_type == "LEADING-LENGTH-INFO-TYPE":
19
18
  return LeadingLengthInfoType.from_et(et_element, doc_frags)
odxtools/database.py CHANGED
@@ -1,8 +1,9 @@
1
1
  # SPDX-License-Identifier: MIT
2
+ from collections import OrderedDict
2
3
  from itertools import chain
3
4
  from os import PathLike
4
5
  from pathlib import Path
5
- from typing import IO, Any, Dict, List, Optional, OrderedDict, Union
6
+ from typing import IO, Any, Union
6
7
  from xml.etree import ElementTree
7
8
  from zipfile import ZipFile
8
9
 
@@ -30,7 +31,7 @@ class Database:
30
31
  """
31
32
 
32
33
  def __init__(self) -> None:
33
- self.model_version: Optional[Version] = None
34
+ self.model_version: Version | None = None
34
35
  self.auxiliary_files: OrderedDict[str, IO[bytes]] = OrderedDict()
35
36
 
36
37
  # create an empty database object
@@ -68,16 +69,16 @@ class Database:
68
69
 
69
70
  def add_auxiliary_file(self,
70
71
  aux_file_name: Union[str, "PathLike[Any]"],
71
- aux_file_obj: Optional[IO[bytes]] = None) -> None:
72
+ aux_file_obj: IO[bytes] | None = None) -> None:
72
73
  if aux_file_obj is None:
73
74
  aux_file_obj = open(aux_file_name, "rb")
74
75
 
75
76
  self.auxiliary_files[str(aux_file_name)] = aux_file_obj
76
77
 
77
78
  def _process_xml_tree(self, root: ElementTree.Element) -> None:
78
- dlcs: List[DiagLayerContainer] = []
79
- comparam_subsets: List[ComparamSubset] = []
80
- comparam_specs: List[ComparamSpec] = []
79
+ dlcs: list[DiagLayerContainer] = []
80
+ comparam_subsets: list[ComparamSubset] = []
81
+ comparam_specs: list[ComparamSpec] = []
81
82
 
82
83
  # ODX spec version
83
84
  model_version = Version(root.attrib.get("MODEL-VERSION", "2.0"))
@@ -160,8 +161,8 @@ class Database:
160
161
  for dlc in self.diag_layer_containers:
161
162
  dlc._resolve_snrefs(context)
162
163
 
163
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
164
- result: Dict[OdxLinkId, Any] = {}
164
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
165
+ result: dict[OdxLinkId, Any] = {}
165
166
 
166
167
  for subset in self.comparam_subsets:
167
168
  result.update(subset._build_odxlinks())
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import Any, Dict, List, Optional, cast
3
+ from typing import Any, cast
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .compumethods.compumethod import CompuMethod
@@ -37,20 +37,20 @@ class DataObjectProperty(DopBase):
37
37
  #: The type of the value in the physical world
38
38
  physical_type: PhysicalType
39
39
 
40
- internal_constr: Optional[InternalConstr]
40
+ internal_constr: InternalConstr | None
41
41
 
42
42
  #: The unit associated with physical values (e.g. 'm/s^2')
43
- unit_ref: Optional[OdxLinkRef]
43
+ unit_ref: OdxLinkRef | None
44
44
 
45
- physical_constr: Optional[InternalConstr]
45
+ physical_constr: InternalConstr | None
46
46
 
47
47
  @property
48
- def unit(self) -> Optional[Unit]:
48
+ def unit(self) -> Unit | None:
49
49
  return self._unit
50
50
 
51
51
  @staticmethod
52
52
  def from_et(et_element: ElementTree.Element,
53
- doc_frags: List[OdxDocFragment]) -> "DataObjectProperty":
53
+ doc_frags: list[OdxDocFragment]) -> "DataObjectProperty":
54
54
  """Reads a DATA-OBJECT-PROP."""
55
55
  kwargs = dataclass_fields_asdict(DopBase.from_et(et_element, doc_frags))
56
56
 
@@ -83,7 +83,7 @@ class DataObjectProperty(DopBase):
83
83
  physical_constr=physical_constr,
84
84
  **kwargs)
85
85
 
86
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
86
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
87
87
  result = super()._build_odxlinks()
88
88
  result.update(self.compu_method._build_odxlinks())
89
89
  result.update(self.diag_coded_type._build_odxlinks())
@@ -96,7 +96,7 @@ class DataObjectProperty(DopBase):
96
96
  self.compu_method._resolve_odxlinks(odxlinks)
97
97
  self.diag_coded_type._resolve_odxlinks(odxlinks)
98
98
 
99
- self._unit: Optional[Unit] = None
99
+ self._unit: Unit | None = None
100
100
  if self.unit_ref:
101
101
  self._unit = odxlinks.resolve(self.unit_ref, Unit)
102
102
 
@@ -106,7 +106,7 @@ class DataObjectProperty(DopBase):
106
106
  self.compu_method._resolve_snrefs(context)
107
107
  self.diag_coded_type._resolve_snrefs(context)
108
108
 
109
- def get_static_bit_length(self) -> Optional[int]:
109
+ def get_static_bit_length(self) -> int | None:
110
110
  return self.diag_coded_type.get_static_bit_length()
111
111
 
112
112
  def encode_into_pdu(self, physical_value: ParameterValue, encode_state: EncodeState) -> None:
@@ -118,7 +118,7 @@ class DataObjectProperty(DopBase):
118
118
  f"The value {repr(physical_value)} of type {type(physical_value).__name__}"
119
119
  f" is not a valid.")
120
120
 
121
- if not isinstance(physical_value, (int, float, str, BytesTypes)):
121
+ if not isinstance(physical_value, int | float | str | BytesTypes):
122
122
  odxraise(f"Invalid type '{type(physical_value).__name__}' for physical value. "
123
123
  f"(Expect atomic type!)")
124
124
  internal_value = self.compu_method.convert_physical_to_internal(physical_value)
odxtools/decodestate.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass, field
3
- from typing import TYPE_CHECKING, Dict, List, Optional, Tuple
3
+ from typing import TYPE_CHECKING
4
4
 
5
5
  from .encoding import Encoding, get_string_encoding
6
6
  from .exceptions import DecodeError, odxassert, odxraise, strict_mode
@@ -41,22 +41,22 @@ class DecodeState:
41
41
  cursor_bit_position: int = 0
42
42
 
43
43
  #: values of the length key parameters decoded so far
44
- length_keys: Dict[str, int] = field(default_factory=dict)
44
+ length_keys: dict[str, int] = field(default_factory=dict)
45
45
 
46
46
  #: values of the table key parameters decoded so far
47
- table_keys: Dict[str, "TableRow"] = field(default_factory=dict)
47
+ table_keys: dict[str, "TableRow"] = field(default_factory=dict)
48
48
 
49
49
  #: List of parameters that have been decoded so far. The journal
50
50
  #: is used by some types of parameters which depend on the values of
51
51
  #: other parameters; i.e., environment data description parameters
52
- journal: List[Tuple["Parameter", Optional[ParameterValue]]] = field(default_factory=list)
52
+ journal: list[tuple["Parameter", ParameterValue | None]] = field(default_factory=list)
53
53
 
54
54
  def extract_atomic_value(
55
55
  self,
56
56
  *,
57
57
  bit_length: int,
58
58
  base_data_type: DataType,
59
- base_type_encoding: Optional[Encoding],
59
+ base_type_encoding: Encoding | None,
60
60
  is_highlow_byte_order: bool,
61
61
  ) -> AtomicOdxType:
62
62
  """Extract an internal value from a blob of raw bytes.
odxtools/description.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from dataclasses import dataclass
2
- from typing import List, Optional
2
+ from typing import Optional
3
3
  from xml.etree import ElementTree
4
4
 
5
5
  from .exceptions import odxrequire
@@ -10,13 +10,13 @@ from .odxlink import OdxDocFragment
10
10
  @dataclass
11
11
  class Description:
12
12
  text: str
13
- external_docs: List[ExternalDoc]
13
+ external_docs: list[ExternalDoc]
14
14
 
15
- text_identifier: Optional[str]
15
+ text_identifier: str | None
16
16
 
17
17
  @staticmethod
18
- def from_et(et_element: Optional[ElementTree.Element],
19
- doc_frags: List[OdxDocFragment]) -> Optional["Description"]:
18
+ def from_et(et_element: ElementTree.Element | None,
19
+ doc_frags: list[OdxDocFragment]) -> Optional["Description"]:
20
20
  if et_element is None:
21
21
  return None
22
22
 
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import Any, Dict, List, Optional
3
+ from typing import Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .dataobjectproperty import DataObjectProperty
@@ -15,7 +15,7 @@ class DetermineNumberOfItems:
15
15
  The object that determines the number of items of dynamic fields
16
16
  """
17
17
  byte_position: int
18
- bit_position: Optional[int]
18
+ bit_position: int | None
19
19
  dop_ref: OdxLinkRef
20
20
 
21
21
  @property
@@ -24,7 +24,7 @@ class DetermineNumberOfItems:
24
24
 
25
25
  @staticmethod
26
26
  def from_et(et_element: ElementTree.Element,
27
- doc_frags: List[OdxDocFragment]) -> "DetermineNumberOfItems":
27
+ doc_frags: list[OdxDocFragment]) -> "DetermineNumberOfItems":
28
28
  byte_position = int(odxrequire(et_element.findtext("BYTE-POSITION")))
29
29
  bit_position_str = et_element.findtext("BIT-POSITION")
30
30
  bit_position = int(bit_position_str) if bit_position_str is not None else None
@@ -36,7 +36,7 @@ class DetermineNumberOfItems:
36
36
  dop_ref=dop_ref,
37
37
  )
38
38
 
39
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
39
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
40
40
  return {}
41
41
 
42
42
  def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None:
odxtools/diagcodedtype.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import Any, Dict, List, Literal, Optional, Union, cast
3
+ from typing import Any, Literal, cast
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .decodestate import DecodeState
@@ -22,10 +22,10 @@ DctType = Literal[
22
22
 
23
23
  @dataclass
24
24
  class DiagCodedType:
25
- base_type_encoding: Optional[Encoding]
25
+ base_type_encoding: Encoding | None
26
26
  base_data_type: DataType
27
27
 
28
- is_highlow_byte_order_raw: Optional[bool]
28
+ is_highlow_byte_order_raw: bool | None
29
29
 
30
30
  @property
31
31
  def dct_type(self) -> DctType:
@@ -39,7 +39,7 @@ class DiagCodedType:
39
39
 
40
40
  @staticmethod
41
41
  def from_et(et_element: ElementTree.Element,
42
- doc_frags: List[OdxDocFragment]) -> "DiagCodedType":
42
+ doc_frags: list[OdxDocFragment]) -> "DiagCodedType":
43
43
  base_type_encoding = None
44
44
  if (base_type_encoding_str := et_element.get("BASE-TYPE-ENCODING")) is not None:
45
45
  try:
@@ -61,7 +61,7 @@ class DiagCodedType:
61
61
  base_data_type=base_data_type,
62
62
  is_highlow_byte_order_raw=is_highlow_byte_order_raw)
63
63
 
64
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]: # noqa: B027
64
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]: # noqa: B027
65
65
  return {}
66
66
 
67
67
  def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None: # noqa: B027
@@ -72,10 +72,10 @@ class DiagCodedType:
72
72
  """Recursively resolve any short-name references"""
73
73
  pass
74
74
 
75
- def get_static_bit_length(self) -> Optional[int]:
75
+ def get_static_bit_length(self) -> int | None:
76
76
  return None
77
77
 
78
- def _minimal_byte_length_of(self, internal_value: Union[bytes, str]) -> int:
78
+ def _minimal_byte_length_of(self, internal_value: bytes | str) -> int:
79
79
  """Helper method to get the minimal byte length.
80
80
  (needed for LeadingLength- and MinMaxLengthType)
81
81
  """
odxtools/diagcomm.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import TYPE_CHECKING, Any, Dict, List, Optional
3
+ from typing import TYPE_CHECKING, Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .admindata import AdminData
@@ -34,21 +34,21 @@ class DiagComm(IdentifiableElement):
34
34
 
35
35
  """
36
36
 
37
- admin_data: Optional[AdminData]
38
- sdgs: List[SpecialDataGroup]
39
- functional_class_refs: List[OdxLinkRef]
40
- audience: Optional[Audience]
41
- protocol_snrefs: List[str]
42
- related_diag_comm_refs: List[RelatedDiagCommRef]
43
- pre_condition_state_refs: List[PreConditionStateRef]
44
- state_transition_refs: List[StateTransitionRef]
37
+ admin_data: AdminData | None
38
+ sdgs: list[SpecialDataGroup]
39
+ functional_class_refs: list[OdxLinkRef]
40
+ audience: Audience | None
41
+ protocol_snrefs: list[str]
42
+ related_diag_comm_refs: list[RelatedDiagCommRef]
43
+ pre_condition_state_refs: list[PreConditionStateRef]
44
+ state_transition_refs: list[StateTransitionRef]
45
45
 
46
46
  # attributes
47
- semantic: Optional[str]
48
- diagnostic_class: Optional[DiagClassType]
49
- is_mandatory_raw: Optional[bool]
50
- is_executable_raw: Optional[bool]
51
- is_final_raw: Optional[bool]
47
+ semantic: str | None
48
+ diagnostic_class: DiagClassType | None
49
+ is_mandatory_raw: bool | None
50
+ is_executable_raw: bool | None
51
+ is_final_raw: bool | None
52
52
 
53
53
  @property
54
54
  def functional_classes(self) -> NamedItemList[FunctionalClass]:
@@ -83,7 +83,7 @@ class DiagComm(IdentifiableElement):
83
83
  return self.is_final_raw is True
84
84
 
85
85
  @staticmethod
86
- def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "DiagComm":
86
+ def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "DiagComm":
87
87
  kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
88
88
 
89
89
  admin_data = AdminData.from_et(et_element.find("ADMIN-DATA"), doc_frags)
@@ -122,7 +122,7 @@ class DiagComm(IdentifiableElement):
122
122
 
123
123
  semantic = et_element.attrib.get("SEMANTIC")
124
124
 
125
- diagnostic_class: Optional[DiagClassType] = None
125
+ diagnostic_class: DiagClassType | None = None
126
126
  if (diagnostic_class_str := et_element.attrib.get("DIAGNOSTIC-CLASS")) is not None:
127
127
  try:
128
128
  diagnostic_class = DiagClassType(diagnostic_class_str)
@@ -149,7 +149,7 @@ class DiagComm(IdentifiableElement):
149
149
  is_final_raw=is_final_raw,
150
150
  **kwargs)
151
151
 
152
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
152
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
153
153
  result = {self.odx_id: self}
154
154
 
155
155
  if self.admin_data is not None:
@@ -1,7 +1,7 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
3
  from itertools import chain
4
- from typing import Any, Dict, List, Optional
4
+ from typing import Any
5
5
  from xml.etree import ElementTree
6
6
 
7
7
  from .admindata import AdminData
@@ -26,7 +26,7 @@ from .unitspec import UnitSpec
26
26
 
27
27
  @dataclass
28
28
  class DiagDataDictionarySpec:
29
- admin_data: Optional[AdminData]
29
+ admin_data: AdminData | None
30
30
  dtc_dops: NamedItemList[DtcDop]
31
31
  env_data_descs: NamedItemList[EnvironmentDataDescription]
32
32
  data_object_props: NamedItemList[DataObjectProperty]
@@ -37,13 +37,13 @@ class DiagDataDictionarySpec:
37
37
  end_of_pdu_fields: NamedItemList[EndOfPduField]
38
38
  muxs: NamedItemList[Multiplexer]
39
39
  env_datas: NamedItemList[EnvironmentData]
40
- unit_spec: Optional[UnitSpec]
40
+ unit_spec: UnitSpec | None
41
41
  tables: NamedItemList[Table]
42
- sdgs: List[SpecialDataGroup]
42
+ sdgs: list[SpecialDataGroup]
43
43
 
44
44
  @staticmethod
45
45
  def from_et(et_element: ElementTree.Element,
46
- doc_frags: List[OdxDocFragment]) -> "DiagDataDictionarySpec":
46
+ doc_frags: list[OdxDocFragment]) -> "DiagDataDictionarySpec":
47
47
  admin_data = None
48
48
  if (admin_data_elem := et_element.find("ADMIN-DATA")) is not None:
49
49
  admin_data = AdminData.from_et(admin_data_elem, doc_frags)
@@ -149,7 +149,7 @@ class DiagDataDictionarySpec:
149
149
  self.env_datas,
150
150
  ))
151
151
 
152
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
152
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
153
153
  # note that DataDictionarySpec objects do not exhibit an ODXLINK id.
154
154
  odxlinks = {}
155
155
 
@@ -1,7 +1,7 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
3
  from itertools import chain
4
- from typing import TYPE_CHECKING, Any, Dict, List, Union
4
+ from typing import TYPE_CHECKING, Any
5
5
  from xml.etree import ElementTree
6
6
 
7
7
  from .diaglayers.basevariant import BaseVariant
@@ -41,7 +41,7 @@ class DiagLayerContainer(OdxCategory):
41
41
 
42
42
  @staticmethod
43
43
  def from_et(et_element: ElementTree.Element,
44
- doc_frags: List[OdxDocFragment]) -> "DiagLayerContainer":
44
+ doc_frags: list[OdxDocFragment]) -> "DiagLayerContainer":
45
45
 
46
46
  cat = OdxCategory.category_from_et(et_element, doc_frags, doc_type=DocType.CONTAINER)
47
47
  doc_frags = cat.odx_id.doc_fragments
@@ -85,7 +85,7 @@ class DiagLayerContainer(OdxCategory):
85
85
  self.ecu_variants,
86
86
  ),)
87
87
 
88
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
88
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
89
89
  result = super()._build_odxlinks()
90
90
 
91
91
  for protocol in self.protocols:
@@ -132,5 +132,5 @@ class DiagLayerContainer(OdxCategory):
132
132
  def _resolve_snrefs(self, context: SnRefContext) -> None:
133
133
  super()._resolve_snrefs(context)
134
134
 
135
- def __getitem__(self, key: Union[int, str]) -> DiagLayer:
135
+ def __getitem__(self, key: int | str) -> DiagLayer:
136
136
  return self.diag_layers[key]
@@ -1,7 +1,8 @@
1
1
  # SPDX-License-Identifier: MIT
2
+ from collections.abc import Iterable
2
3
  from copy import deepcopy
3
4
  from dataclasses import dataclass
4
- from typing import Any, Dict, Iterable, List, Optional, Union, cast
5
+ from typing import Any, cast
5
6
  from xml.etree import ElementTree
6
7
 
7
8
  from typing_extensions import override
@@ -32,19 +33,19 @@ class BaseVariant(HierarchyElement):
32
33
  # <properties forwarded to the "raw" base variant>
33
34
  #####
34
35
  @property
35
- def diag_variables_raw(self) -> List[Union[DiagVariable, OdxLinkRef]]:
36
+ def diag_variables_raw(self) -> list[DiagVariable | OdxLinkRef]:
36
37
  return self.base_variant_raw.diag_variables_raw
37
38
 
38
39
  @property
39
- def dyn_defined_spec(self) -> Optional[DynDefinedSpec]:
40
+ def dyn_defined_spec(self) -> DynDefinedSpec | None:
40
41
  return self.base_variant_raw.dyn_defined_spec
41
42
 
42
43
  @property
43
- def base_variant_pattern(self) -> Optional[BaseVariantPattern]:
44
+ def base_variant_pattern(self) -> BaseVariantPattern | None:
44
45
  return self.base_variant_raw.base_variant_pattern
45
46
 
46
47
  @property
47
- def parent_refs(self) -> List[ParentRef]:
48
+ def parent_refs(self) -> list[ParentRef]:
48
49
  return self.base_variant_raw.parent_refs
49
50
 
50
51
  #####
@@ -67,7 +68,7 @@ class BaseVariant(HierarchyElement):
67
68
  #######
68
69
 
69
70
  @staticmethod
70
- def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "BaseVariant":
71
+ def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "BaseVariant":
71
72
  base_variant_raw = BaseVariantRaw.from_et(et_element, doc_frags)
72
73
 
73
74
  return BaseVariant(diag_layer_raw=base_variant_raw)
@@ -80,7 +81,7 @@ class BaseVariant(HierarchyElement):
80
81
  "The raw diagnostic layer passed to BaseVariant "
81
82
  "must be a BaseVariantRaw")
82
83
 
83
- def __deepcopy__(self, memo: Dict[int, Any]) -> Any:
84
+ def __deepcopy__(self, memo: dict[int, Any]) -> Any:
84
85
  """Create a deep copy of the base variant
85
86
 
86
87
  Note that the copied diagnostic layer is not fully
@@ -113,7 +114,7 @@ class BaseVariant(HierarchyElement):
113
114
 
114
115
  return dl.diag_layer_raw.diag_variables # type: ignore[no-any-return]
115
116
 
116
- def not_inherited_fn(parent_ref: ParentRef) -> List[str]:
117
+ def not_inherited_fn(parent_ref: ParentRef) -> list[str]:
117
118
  return parent_ref.not_inherited_variables
118
119
 
119
120
  return self._compute_available_objects(get_local_objects_fn, not_inherited_fn)
@@ -127,7 +128,7 @@ class BaseVariant(HierarchyElement):
127
128
 
128
129
  return dl.diag_layer_raw.variable_groups # type: ignore[no-any-return]
129
130
 
130
- def not_inherited_fn(parent_ref: ParentRef) -> List[str]:
131
+ def not_inherited_fn(parent_ref: ParentRef) -> list[str]:
131
132
  return []
132
133
 
133
134
  return self._compute_available_objects(get_local_objects_fn, not_inherited_fn)
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import Any, Dict, List, Optional, Union
3
+ from typing import Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from ..basevariantpattern import BaseVariantPattern
@@ -21,11 +21,11 @@ class BaseVariantRaw(HierarchyElementRaw):
21
21
  """This is a diagnostic layer for common functionality of an ECU
22
22
  """
23
23
 
24
- diag_variables_raw: List[Union[DiagVariable, OdxLinkRef]]
24
+ diag_variables_raw: list[DiagVariable | OdxLinkRef]
25
25
  variable_groups: NamedItemList[VariableGroup]
26
- dyn_defined_spec: Optional[DynDefinedSpec]
27
- base_variant_pattern: Optional[BaseVariantPattern]
28
- parent_refs: List[ParentRef]
26
+ dyn_defined_spec: DynDefinedSpec | None
27
+ base_variant_pattern: BaseVariantPattern | None
28
+ parent_refs: list[ParentRef]
29
29
 
30
30
  @property
31
31
  def diag_variables(self) -> NamedItemList[DiagVariable]:
@@ -33,7 +33,7 @@ class BaseVariantRaw(HierarchyElementRaw):
33
33
 
34
34
  @staticmethod
35
35
  def from_et(et_element: ElementTree.Element,
36
- doc_frags: List[OdxDocFragment]) -> "BaseVariantRaw":
36
+ doc_frags: list[OdxDocFragment]) -> "BaseVariantRaw":
37
37
  # objects contained by diagnostic layers exibit an additional
38
38
  # document fragment for the diag layer, so we use the document
39
39
  # fragments of the odx id of the diag layer for IDs of
@@ -42,10 +42,10 @@ class BaseVariantRaw(HierarchyElementRaw):
42
42
  kwargs = dataclass_fields_asdict(her)
43
43
  doc_frags = her.odx_id.doc_fragments
44
44
 
45
- diag_variables_raw: List[Union[DiagVariable, OdxLinkRef]] = []
45
+ diag_variables_raw: list[DiagVariable | OdxLinkRef] = []
46
46
  if (dv_elems := et_element.find("DIAG-VARIABLES")) is not None:
47
47
  for dv_proxy_elem in dv_elems:
48
- dv_proxy: Union[OdxLinkRef, DiagVariable]
48
+ dv_proxy: OdxLinkRef | DiagVariable
49
49
  if dv_proxy_elem.tag == "DIAG-VARIABLE-REF":
50
50
  dv_proxy = OdxLinkRef.from_et(dv_proxy_elem, doc_frags)
51
51
  elif dv_proxy_elem.tag == "DIAG-VARIABLE":
@@ -81,7 +81,7 @@ class BaseVariantRaw(HierarchyElementRaw):
81
81
  parent_refs=parent_refs,
82
82
  **kwargs)
83
83
 
84
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
84
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
85
85
  result = super()._build_odxlinks()
86
86
 
87
87
  for dv_proxy in self.diag_variables_raw: