Skip to content

Commit acfbfea

Browse files
authored
Merge pull request #397 from andlaus/small_fixes
Small fixes
2 parents 7415c53 + f2a96d7 commit acfbfea

9 files changed

+24
-23
lines changed

.github/workflows/tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Set up Python
2121
uses: actions/setup-python@v4
2222
with:
23-
python-version: "3.12"
23+
python-version: "3"
2424

2525
- name: Setup up YaPF formatting linter
2626
run: |
@@ -38,7 +38,7 @@ jobs:
3838
matrix:
3939
# restrict the matrix to the oldest and the latest Python
4040
# version being supported by odxtools
41-
python-version: ["3.8", "3.12"]
41+
python-version: ["3.8", "3"]
4242

4343
steps:
4444
- uses: actions/checkout@v3
@@ -73,7 +73,7 @@ jobs:
7373
os: [ubuntu-latest, windows-latest]
7474
# restrict the matrix to the oldest and the latest Python
7575
# version being supported by odxtools
76-
python-version: ["3.8", "3.12"]
76+
python-version: ["3.8", "3"]
7777

7878
# due to the slow windows runners, we refrain from testing every python
7979
# version on windows-latest

odxtools/dataobjectproperty.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
from .exceptions import EncodeError, odxraise, odxrequire
1414
from .internalconstr import InternalConstr
1515
from .odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId, OdxLinkRef
16-
from .odxtypes import AtomicOdxType, ParameterValue
16+
from .odxtypes import AtomicOdxType, BytesTypes, ParameterValue
1717
from .physicaltype import PhysicalType
1818
from .snrefcontext import SnRefContext
1919
from .unit import Unit
20-
from .utils import BytesTypes, dataclass_fields_asdict
20+
from .utils import dataclass_fields_asdict
2121

2222

2323
@dataclass

odxtools/encodestate.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
from .encoding import Encoding, get_string_encoding
77
from .exceptions import EncodeError, OdxWarning, odxassert, odxraise
8-
from .odxtypes import AtomicOdxType, DataType, ParameterValue
9-
from .utils import BytesTypes
8+
from .odxtypes import AtomicOdxType, BytesTypes, DataType, ParameterValue
109

1110
try:
1211
import bitstruct.c as bitstruct

odxtools/matchingparameter.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
from .diagservice import DiagService
99
from .exceptions import odxraise, odxrequire
1010
from .odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId, resolve_snref
11-
from .odxtypes import ParameterValue, ParameterValueDict
11+
from .odxtypes import BytesTypes, ParameterValue, ParameterValueDict
1212
from .snrefcontext import SnRefContext
13-
from .utils import BytesTypes
1413

1514

1615
@dataclass

odxtools/minmaxlengthtype.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from .diagcodedtype import DctType, DiagCodedType
1111
from .encodestate import EncodeState
1212
from .encoding import get_string_encoding
13-
from .exceptions import (DecodeError, EncodeError, odxassert, odxraise, odxrequire)
13+
from .exceptions import DecodeError, EncodeError, odxassert, odxraise, odxrequire
1414
from .odxlink import OdxDocFragment
15-
from .odxtypes import AtomicOdxType, DataType
16-
from .utils import BytesTypes, dataclass_fields_asdict
15+
from .odxtypes import AtomicOdxType, BytesTypes, DataType
16+
from .utils import dataclass_fields_asdict
1717

1818

1919
class Termination(Enum):

odxtools/odxtypes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# SPDX-License-Identifier: MIT
22
from enum import Enum
3-
from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterable, Optional, Tuple, Type, Union,
4-
overload)
3+
from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterable, Optional, SupportsBytes, Tuple,
4+
Type, Union, overload)
55
from xml.etree import ElementTree
66

77
from .exceptions import odxassert, odxraise, odxrequire
8-
from .utils import BytesTypes
98

109
if TYPE_CHECKING:
1110
from odxtools.diagnostictroublecode import DiagnosticTroubleCode
@@ -17,7 +16,8 @@ def bytefield_to_bytearray(bytefield: str) -> bytearray:
1716
return bytearray([int(x, 16) for x in bytes_string])
1817

1918

20-
AtomicOdxType = Union[str, int, float, bytes]
19+
BytesTypes = (bytearray, bytes, SupportsBytes)
20+
AtomicOdxType = Union[str, int, float, bytearray, bytes]
2121

2222
# dictionary mapping short names to a Parameter that needs to be
2323
# specified. Complex parameters (structures) may contain

odxtools/parameters/tablestructparameter.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: MIT
22
from dataclasses import dataclass
3-
from typing import Any, Dict, List, Optional, cast
3+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast
44
from xml.etree import ElementTree
55

66
from typing_extensions import override
@@ -15,6 +15,9 @@
1515
from .parameter import Parameter, ParameterType
1616
from .tablekeyparameter import TableKeyParameter
1717

18+
if TYPE_CHECKING:
19+
from ..table import Table
20+
1821

1922
@dataclass
2023
class TableStructParameter(Parameter):
@@ -69,6 +72,10 @@ def _resolve_snrefs(self, context: SnRefContext) -> None:
6972
def table_key(self) -> TableKeyParameter:
7073
return self._table_key
7174

75+
@property
76+
def table(self) -> "Table":
77+
return self._table_key.table
78+
7279
@property
7380
@override
7481
def is_required(self) -> bool:

odxtools/standardlengthtype.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from .encodestate import EncodeState
1111
from .exceptions import odxassert, odxraise, odxrequire
1212
from .odxlink import OdxDocFragment
13-
from .odxtypes import AtomicOdxType, DataType, odxstr_to_bool
14-
from .utils import BytesTypes, dataclass_fields_asdict
13+
from .odxtypes import AtomicOdxType, BytesTypes, DataType, odxstr_to_bool
14+
from .utils import dataclass_fields_asdict
1515

1616

1717
@dataclass

odxtools/utils.py

-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
import re
44
from typing import TYPE_CHECKING, Any, Dict, Optional
55

6-
from typing_extensions import SupportsBytes
7-
86
if TYPE_CHECKING:
97
from .database import Database
108
from .diaglayers.diaglayer import DiagLayer
119
from .snrefcontext import SnRefContext
1210

13-
BytesTypes = (bytearray, bytes, SupportsBytes)
14-
1511

1612
def retarget_snrefs(database: "Database",
1713
diag_layer: "DiagLayer",

0 commit comments

Comments
 (0)