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 Any, Dict, List
3
+ from typing import Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .element import IdentifiableElement
@@ -14,12 +14,12 @@ class SpecialDataGroupCaption(IdentifiableElement):
14
14
 
15
15
  @staticmethod
16
16
  def from_et(et_element: ElementTree.Element,
17
- doc_frags: List[OdxDocFragment]) -> "SpecialDataGroupCaption":
17
+ doc_frags: list[OdxDocFragment]) -> "SpecialDataGroupCaption":
18
18
  kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
19
19
 
20
20
  return SpecialDataGroupCaption(**kwargs)
21
21
 
22
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
22
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
23
23
  result = {self.odx_id: self}
24
24
 
25
25
  result[self.odx_id] = self
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, Literal, Optional
3
+ from typing import Literal
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from typing_extensions import override
@@ -14,12 +14,12 @@ from .odxtypes import AtomicOdxType, BytesTypes, DataType, odxstr_to_bool
14
14
  from .utils import dataclass_fields_asdict, read_hex_binary
15
15
 
16
16
 
17
- @dataclass
17
+ @dataclass(kw_only=True)
18
18
  class StandardLengthType(DiagCodedType):
19
19
 
20
20
  bit_length: int
21
- bit_mask: Optional[int]
22
- is_condensed_raw: Optional[bool]
21
+ bit_mask: int | None = None
22
+ is_condensed_raw: bool | None = None
23
23
 
24
24
  @property
25
25
  def dct_type(self) -> DctType:
@@ -32,7 +32,7 @@ class StandardLengthType(DiagCodedType):
32
32
  @staticmethod
33
33
  @override
34
34
  def from_et(et_element: ElementTree.Element,
35
- doc_frags: List[OdxDocFragment]) -> "StandardLengthType":
35
+ doc_frags: list[OdxDocFragment]) -> "StandardLengthType":
36
36
  kwargs = dataclass_fields_asdict(DiagCodedType.from_et(et_element, doc_frags))
37
37
 
38
38
  bit_length = int(odxrequire(et_element.findtext("BIT-LENGTH")))
@@ -50,7 +50,7 @@ class StandardLengthType(DiagCodedType):
50
50
  'Can not apply a bit_mask on a value of type {self.base_data_type}',
51
51
  )
52
52
 
53
- def __get_used_mask(self, internal_value: AtomicOdxType) -> Optional[bytes]:
53
+ def __get_used_mask(self, internal_value: AtomicOdxType) -> bytes | None:
54
54
  """Returns a byte field where all bits that are used by the
55
55
  DiagCoded type are set and all unused ones are not set.
56
56
 
@@ -118,7 +118,7 @@ class StandardLengthType(DiagCodedType):
118
118
  mask_bit += 1
119
119
 
120
120
  if isinstance(internal_value, BytesTypes):
121
- return result.to_bytes(len(internal_value), 'big')
121
+ return result.to_bytes(len(bytes(internal_value)), 'big')
122
122
 
123
123
  return result
124
124
 
@@ -156,7 +156,7 @@ class StandardLengthType(DiagCodedType):
156
156
  mask_bit += 1
157
157
 
158
158
  if isinstance(raw_value, BytesTypes):
159
- return result.to_bytes(len(raw_value), 'big')
159
+ return result.to_bytes(len(bytes(raw_value)), 'big')
160
160
 
161
161
  return result
162
162
  if isinstance(raw_value, int):
@@ -164,12 +164,12 @@ class StandardLengthType(DiagCodedType):
164
164
  if isinstance(raw_value, BytesTypes):
165
165
  int_value = int.from_bytes(raw_value, 'big')
166
166
  int_value &= self.bit_mask
167
- return int_value.to_bytes(len(raw_value), 'big')
167
+ return int_value.to_bytes(len(bytes(raw_value)), 'big')
168
168
 
169
169
  odxraise(f'Can not apply a bit_mask on a value of type {type(raw_value)}')
170
170
  return raw_value
171
171
 
172
- def get_static_bit_length(self) -> Optional[int]:
172
+ def get_static_bit_length(self) -> int | None:
173
173
  if self.bit_mask is not None and self.is_condensed:
174
174
  # TODO: this is pretty slow. replace it by
175
175
  # `self.bit_mask.bit_count()` once we require python >=
odxtools/state.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
3
+ from typing import Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .element import IdentifiableElement
@@ -16,12 +16,12 @@ class State(IdentifiableElement):
16
16
  """
17
17
 
18
18
  @staticmethod
19
- def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "State":
19
+ def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "State":
20
20
  kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
21
21
 
22
22
  return State(**kwargs)
23
23
 
24
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
24
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
25
25
  return {self.odx_id: self}
26
26
 
27
27
  def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None:
odxtools/statechart.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
3
+ from typing import Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .element import IdentifiableElement
@@ -19,7 +19,7 @@ class StateChart(IdentifiableElement):
19
19
  Corresponds to STATE-CHART.
20
20
  """
21
21
  semantic: str
22
- state_transitions: List[StateTransition]
22
+ state_transitions: list[StateTransition]
23
23
  start_state_snref: str
24
24
  states: NamedItemList[State]
25
25
 
@@ -28,7 +28,7 @@ class StateChart(IdentifiableElement):
28
28
  return self._start_state
29
29
 
30
30
  @staticmethod
31
- def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "StateChart":
31
+ def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "StateChart":
32
32
  kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
33
33
 
34
34
  semantic: str = odxrequire(et_element.findtext("SEMANTIC"))
@@ -52,7 +52,7 @@ class StateChart(IdentifiableElement):
52
52
  states=NamedItemList(states),
53
53
  **kwargs)
54
54
 
55
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
55
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
56
56
  odxlinks = {self.odx_id: self}
57
57
 
58
58
  for strans in self.state_transitions:
odxtools/statemachine.py CHANGED
@@ -1,6 +1,7 @@
1
1
  # SPDX-License-Identifier: MIT
2
+ from collections.abc import Generator
2
3
  from dataclasses import dataclass
3
- from typing import TYPE_CHECKING, Any, Generator, Union
4
+ from typing import TYPE_CHECKING, Any
4
5
 
5
6
  from .exceptions import odxraise
6
7
  from .odxtypes import ParameterValueDict
@@ -97,7 +98,7 @@ class StateMachine:
97
98
  self._active_state = state_chart.start_state
98
99
 
99
100
  def execute(self, service: "DiagService", **service_params: Any
100
- ) -> Generator[bytes, Union[bytes, bytearray, ParameterValueDict], None]:
101
+ ) -> Generator[bytes, bytes | bytearray | ParameterValueDict, None]:
101
102
  """Run a diagnostic service and update the state machine
102
103
  depending on the outcome.
103
104
 
@@ -159,7 +160,7 @@ class StateMachine:
159
160
 
160
161
  if raw_resp is None:
161
162
  raise RuntimeError("The calling code must send back a reply")
162
- elif isinstance(raw_resp, (bytes, bytearray)):
163
+ elif isinstance(raw_resp, bytes | bytearray):
163
164
  for decoded_resp_msg in self.diag_layer.decode_response(raw_resp, raw_req):
164
165
  for stransref in service.state_transition_refs:
165
166
  # we only execute the first applicable state
@@ -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 .element import IdentifiableElement
@@ -19,7 +19,7 @@ class StateTransition(IdentifiableElement):
19
19
  """
20
20
  source_snref: str
21
21
  target_snref: str
22
- external_access_method: Optional[ExternalAccessMethod]
22
+ external_access_method: ExternalAccessMethod | None
23
23
 
24
24
  @property
25
25
  def source_state(self) -> State:
@@ -31,7 +31,7 @@ class StateTransition(IdentifiableElement):
31
31
 
32
32
  @staticmethod
33
33
  def from_et(et_element: ElementTree.Element,
34
- doc_frags: List[OdxDocFragment]) -> "StateTransition":
34
+ doc_frags: list[OdxDocFragment]) -> "StateTransition":
35
35
 
36
36
  kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
37
37
 
@@ -50,7 +50,7 @@ class StateTransition(IdentifiableElement):
50
50
  external_access_method=external_access_method,
51
51
  **kwargs)
52
52
 
53
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
53
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
54
54
  return {self.odx_id: self}
55
55
 
56
56
  def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None:
@@ -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, Tuple, Union
3
+ from typing import TYPE_CHECKING, Any, Union
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .basicstructure import BasicStructure
@@ -27,11 +27,11 @@ if TYPE_CHECKING:
27
27
 
28
28
 
29
29
  def _resolve_in_param(
30
- in_param_if_snref: Optional[str],
31
- in_param_if_snpathref: Optional[str],
32
- params: List[Parameter],
30
+ in_param_if_snref: str | None,
31
+ in_param_if_snpathref: str | None,
32
+ params: list[Parameter],
33
33
  param_dict: ParameterValueDict,
34
- ) -> Tuple[Optional[Parameter], Optional[ParameterValue]]:
34
+ ) -> tuple[Parameter | None, ParameterValue | None]:
35
35
 
36
36
  if in_param_if_snref is not None:
37
37
  path_chunks = [in_param_if_snref]
@@ -44,10 +44,10 @@ def _resolve_in_param(
44
44
 
45
45
 
46
46
  def _resolve_in_param_helper(
47
- params: List[Parameter],
47
+ params: list[Parameter],
48
48
  param_dict: ParameterValueDict,
49
- path_chunks: List[str],
50
- ) -> Tuple[Optional[Parameter], Optional[ParameterValue]]:
49
+ path_chunks: list[str],
50
+ ) -> tuple[Parameter | None, ParameterValue | None]:
51
51
 
52
52
  inner_param = resolve_snref(path_chunks[0], params, Parameter, lenient=True)
53
53
  if inner_param is None:
@@ -90,7 +90,7 @@ def _resolve_in_param_helper(
90
90
 
91
91
  def _check_applies(ref: Union["StateTransitionRef",
92
92
  "PreConditionStateRef"], state_machine: "StateMachine",
93
- params: List[Parameter], param_value_dict: ParameterValueDict) -> bool:
93
+ params: list[Parameter], param_value_dict: ParameterValueDict) -> bool:
94
94
  if state_machine.active_state != ref.state:
95
95
  # if the active state of the state machine is not the
96
96
  # specified one, the precondition does not apply
@@ -108,13 +108,13 @@ def _check_applies(ref: Union["StateTransitionRef",
108
108
  return False
109
109
  elif not isinstance(
110
110
  param,
111
- (CodedConstParameter, PhysicalConstantParameter, TableKeyParameter, ValueParameter)):
111
+ CodedConstParameter | PhysicalConstantParameter | TableKeyParameter | ValueParameter):
112
112
  # see checker rule 194 in section B.2 of the spec
113
113
  odxraise(f"Parameter referenced by state transition ref is of "
114
114
  f"invalid type {type(param).__name__}")
115
115
  return False
116
- elif isinstance(param, (CodedConstParameter, PhysicalConstantParameter,
117
- TableKeyParameter)) and ref.value is not None:
116
+ elif isinstance(param, CodedConstParameter | PhysicalConstantParameter
117
+ | TableKeyParameter) and ref.value is not None:
118
118
  # see checker rule 193 in section B.2 of the spec. Why can
119
119
  # no values for constant parameters be specified? (This
120
120
  # seems to be rather inconvenient...)
@@ -155,10 +155,10 @@ class StateTransitionRef(OdxLinkRef):
155
155
  may also be conditional on the observed response of the ECU.
156
156
 
157
157
  """
158
- value: Optional[str]
158
+ value: str | None
159
159
 
160
- in_param_if_snref: Optional[str]
161
- in_param_if_snpathref: Optional[str]
160
+ in_param_if_snref: str | None
161
+ in_param_if_snpathref: str | None
162
162
 
163
163
  @property
164
164
  def state_transition(self) -> StateTransition:
@@ -171,7 +171,7 @@ class StateTransitionRef(OdxLinkRef):
171
171
  @staticmethod
172
172
  def from_et( # type: ignore[override]
173
173
  et_element: ElementTree.Element,
174
- doc_frags: List[OdxDocFragment]) -> "StateTransitionRef":
174
+ doc_frags: list[OdxDocFragment]) -> "StateTransitionRef":
175
175
  kwargs = dataclass_fields_asdict(OdxLinkRef.from_et(et_element, doc_frags))
176
176
 
177
177
  value = et_element.findtext("VALUE")
@@ -195,7 +195,7 @@ class StateTransitionRef(OdxLinkRef):
195
195
  odxassert(self.in_param_if_snref is not None or self.in_param_if_snref is not None,
196
196
  "If VALUE is specified, a parameter must be referenced")
197
197
 
198
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
198
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
199
199
  return {}
200
200
 
201
201
  def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None:
@@ -204,7 +204,7 @@ class StateTransitionRef(OdxLinkRef):
204
204
  def _resolve_snrefs(self, context: SnRefContext) -> None:
205
205
  pass
206
206
 
207
- def execute(self, state_machine: StateMachine, params: List[Parameter],
207
+ def execute(self, state_machine: StateMachine, params: list[Parameter],
208
208
  param_value_dict: ParameterValueDict) -> bool:
209
209
  """Update a StateMachine object if the state transition ought
210
210
  to be executed based on the response received after executing a
odxtools/staticfield.py CHANGED
@@ -1,6 +1,7 @@
1
1
  # SPDX-License-Identifier: MIT
2
+ from collections.abc import Sequence
2
3
  from dataclasses import dataclass
3
- from typing import Any, Dict, List, Sequence
4
+ from typing import Any
4
5
  from xml.etree import ElementTree
5
6
 
6
7
  from typing_extensions import override
@@ -23,7 +24,7 @@ class StaticField(Field):
23
24
 
24
25
  @staticmethod
25
26
  @override
26
- def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "StaticField":
27
+ def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "StaticField":
27
28
  kwargs = dataclass_fields_asdict(Field.from_et(et_element, doc_frags))
28
29
 
29
30
  fixed_number_of_items = int(odxrequire(et_element.findtext('FIXED-NUMBER-OF-ITEMS')))
@@ -33,7 +34,7 @@ class StaticField(Field):
33
34
  fixed_number_of_items=fixed_number_of_items, item_byte_size=item_byte_size, **kwargs)
34
35
 
35
36
  @override
36
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
37
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
37
38
  odxlinks = super()._build_odxlinks()
38
39
  return odxlinks
39
40
 
@@ -89,7 +90,7 @@ class StaticField(Field):
89
90
  orig_origin = decode_state.origin_byte_position
90
91
  decode_state.origin_byte_position = decode_state.cursor_byte_position
91
92
 
92
- result: List[ParameterValue] = []
93
+ result: list[ParameterValue] = []
93
94
  for _ in range(self.fixed_number_of_items):
94
95
  orig_cursor = decode_state.cursor_byte_position
95
96
 
odxtools/structure.py CHANGED
@@ -1,6 +1,5 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, Optional
4
3
  from xml.etree import ElementTree
5
4
 
6
5
  from .basicstructure import BasicStructure
@@ -11,14 +10,14 @@ from .utils import dataclass_fields_asdict
11
10
 
12
11
  @dataclass
13
12
  class Structure(BasicStructure):
14
- is_visible_raw: Optional[bool]
13
+ is_visible_raw: bool | None
15
14
 
16
15
  @property
17
16
  def is_visible(self) -> bool:
18
17
  return self.is_visible_raw in (True, None)
19
18
 
20
19
  @staticmethod
21
- def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "Structure":
20
+ def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "Structure":
22
21
  """Read a STRUCTURE element from XML."""
23
22
  kwargs = dataclass_fields_asdict(BasicStructure.from_et(et_element, doc_frags))
24
23
 
odxtools/subcomponent.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, Optional
3
+ from typing import Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .dtcconnector import DtcConnector
@@ -25,16 +25,16 @@ class SubComponent(IdentifiableElement):
25
25
 
26
26
  """
27
27
 
28
- sub_component_patterns: List[SubComponentPattern]
28
+ sub_component_patterns: list[SubComponentPattern]
29
29
  sub_component_param_connectors: NamedItemList[SubComponentParamConnector]
30
30
  table_row_connectors: NamedItemList[TableRowConnector]
31
31
  env_data_connectors: NamedItemList[EnvDataConnector]
32
32
  dtc_connectors: NamedItemList[DtcConnector]
33
33
 
34
- semantic: Optional[str]
34
+ semantic: str | None
35
35
 
36
36
  @staticmethod
37
- def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "SubComponent":
37
+ def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "SubComponent":
38
38
  kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
39
39
 
40
40
  semantic = et_element.get("SEMANTIC")
@@ -69,7 +69,7 @@ class SubComponent(IdentifiableElement):
69
69
  dtc_connectors=NamedItemList(dtc_connectors),
70
70
  **kwargs)
71
71
 
72
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
72
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
73
73
  result = {}
74
74
 
75
75
  for scp in self.sub_component_patterns:
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import Any, Dict, List
3
+ from typing import Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .diagservice import DiagService
@@ -18,8 +18,8 @@ class SubComponentParamConnector(IdentifiableElement):
18
18
  diag_comm_snref: str
19
19
 
20
20
  # TODO: we currently only support SNREFs, not SNPATHREFs
21
- out_param_if_refs: List[str]
22
- in_param_if_refs: List[str]
21
+ out_param_if_refs: list[str]
22
+ in_param_if_refs: list[str]
23
23
 
24
24
  @property
25
25
  def service(self) -> DiagService:
@@ -35,7 +35,7 @@ class SubComponentParamConnector(IdentifiableElement):
35
35
 
36
36
  @staticmethod
37
37
  def from_et(et_element: ElementTree.Element,
38
- doc_frags: List[OdxDocFragment]) -> "SubComponentParamConnector":
38
+ doc_frags: list[OdxDocFragment]) -> "SubComponentParamConnector":
39
39
  kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
40
40
 
41
41
  diag_comm_snref = odxrequire(
@@ -65,7 +65,7 @@ class SubComponentParamConnector(IdentifiableElement):
65
65
  in_param_if_refs=in_param_if_refs,
66
66
  **kwargs)
67
67
 
68
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
68
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
69
69
  return {}
70
70
 
71
71
  def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None:
@@ -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
3
+ from typing import TYPE_CHECKING, Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId
@@ -12,11 +12,11 @@ if TYPE_CHECKING:
12
12
 
13
13
  @dataclass
14
14
  class SubComponentPattern:
15
- matching_parameters: List["MatchingParameter"]
15
+ matching_parameters: list["MatchingParameter"]
16
16
 
17
17
  @staticmethod
18
18
  def from_et(et_element: ElementTree.Element,
19
- doc_frags: List[OdxDocFragment]) -> "SubComponentPattern":
19
+ doc_frags: list[OdxDocFragment]) -> "SubComponentPattern":
20
20
  from .matchingparameter import MatchingParameter
21
21
 
22
22
  matching_parameters = [
@@ -26,7 +26,7 @@ class SubComponentPattern:
26
26
 
27
27
  return SubComponentPattern(matching_parameters=matching_parameters)
28
28
 
29
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
29
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
30
30
  result = {}
31
31
  for mp in self.matching_parameters:
32
32
  result.update(mp._build_odxlinks())
odxtools/swvariable.py CHANGED
@@ -1,6 +1,5 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, Optional
4
3
  from xml.etree import ElementTree
5
4
 
6
5
  from .element import NamedElement
@@ -10,11 +9,11 @@ from .utils import dataclass_fields_asdict
10
9
 
11
10
  @dataclass
12
11
  class SwVariable(NamedElement):
13
- origin: Optional[str]
14
- oid: Optional[str]
12
+ origin: str | None
13
+ oid: str | None
15
14
 
16
15
  @staticmethod
17
- def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "SwVariable":
16
+ def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "SwVariable":
18
17
  kwargs = dataclass_fields_asdict(NamedElement.from_et(et_element, doc_frags))
19
18
 
20
19
  origin = et_element.findtext("ORIGIN")
odxtools/table.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, Optional, Union
3
+ from typing import Any
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from .admindata import AdminData
@@ -19,17 +19,17 @@ from .utils import dataclass_fields_asdict
19
19
  @dataclass
20
20
  class Table(IdentifiableElement):
21
21
  """This class represents a TABLE."""
22
- key_label: Optional[str]
23
- struct_label: Optional[str]
24
- admin_data: Optional[AdminData]
25
- key_dop_ref: Optional[OdxLinkRef]
26
- table_rows_raw: List[Union[TableRow, OdxLinkRef]]
27
- table_diag_comm_connectors: List[TableDiagCommConnector]
28
- sdgs: List[SpecialDataGroup]
29
- semantic: Optional[str]
22
+ key_label: str | None
23
+ struct_label: str | None
24
+ admin_data: AdminData | None
25
+ key_dop_ref: OdxLinkRef | None
26
+ table_rows_raw: list[TableRow | OdxLinkRef]
27
+ table_diag_comm_connectors: list[TableDiagCommConnector]
28
+ sdgs: list[SpecialDataGroup]
29
+ semantic: str | None
30
30
 
31
31
  @property
32
- def key_dop(self) -> Optional[DataObjectProperty]:
32
+ def key_dop(self) -> DataObjectProperty | None:
33
33
  """The key data object property associated with this table."""
34
34
  return self._key_dop
35
35
 
@@ -39,7 +39,7 @@ class Table(IdentifiableElement):
39
39
  return self._table_rows
40
40
 
41
41
  @staticmethod
42
- def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "Table":
42
+ def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "Table":
43
43
  """Reads a TABLE."""
44
44
  kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
45
45
  odx_id = kwargs["odx_id"]
@@ -48,7 +48,7 @@ class Table(IdentifiableElement):
48
48
  admin_data = AdminData.from_et(et_element.find("ADMIN-DATA"), doc_frags)
49
49
  key_dop_ref = OdxLinkRef.from_et(et_element.find("KEY-DOP-REF"), doc_frags)
50
50
 
51
- table_rows_raw: List[Union[OdxLinkRef, TableRow]] = []
51
+ table_rows_raw: list[OdxLinkRef | TableRow] = []
52
52
  for sub_elem in et_element:
53
53
  if sub_elem.tag == "TABLE-ROW":
54
54
  table_rows_raw.append(
@@ -77,7 +77,7 @@ class Table(IdentifiableElement):
77
77
  semantic=semantic,
78
78
  **kwargs)
79
79
 
80
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
80
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
81
81
  result = {self.odx_id: self}
82
82
 
83
83
  for table_row_wrapper in self.table_rows_raw:
@@ -93,7 +93,7 @@ class Table(IdentifiableElement):
93
93
  return result
94
94
 
95
95
  def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None:
96
- self._key_dop: Optional[DataObjectProperty] = None
96
+ self._key_dop: DataObjectProperty | None = None
97
97
  if self.key_dop_ref is not None:
98
98
  self._key_dop = odxlinks.resolve(self.key_dop_ref, DataObjectProperty)
99
99
 
@@ -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 .diagcomm import DiagComm
@@ -13,8 +13,8 @@ from .snrefcontext import SnRefContext
13
13
  class TableDiagCommConnector:
14
14
  semantic: str
15
15
 
16
- diag_comm_ref: Optional[OdxLinkRef]
17
- diag_comm_snref: Optional[str]
16
+ diag_comm_ref: OdxLinkRef | None
17
+ diag_comm_snref: str | None
18
18
 
19
19
  @property
20
20
  def diag_comm(self) -> DiagComm:
@@ -22,7 +22,7 @@ class TableDiagCommConnector:
22
22
 
23
23
  @staticmethod
24
24
  def from_et(et_element: ElementTree.Element,
25
- doc_frags: List[OdxDocFragment]) -> "TableDiagCommConnector":
25
+ doc_frags: list[OdxDocFragment]) -> "TableDiagCommConnector":
26
26
 
27
27
  semantic = odxrequire(et_element.findtext("SEMANTIC"))
28
28
 
@@ -34,7 +34,7 @@ class TableDiagCommConnector:
34
34
  return TableDiagCommConnector(
35
35
  semantic=semantic, diag_comm_ref=diag_comm_ref, diag_comm_snref=diag_comm_snref)
36
36
 
37
- def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
37
+ def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
38
38
  return {}
39
39
 
40
40
  def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None: