Skip to content

Commit 8223106

Browse files
authored
Merge pull request #407 from andlaus/kw_only
Declare (almost) all dataclasses as `kw_only`
2 parents cb12c81 + 827d4c1 commit 8223106

File tree

153 files changed

+160
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+160
-167
lines changed

examples/somersaultecu.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -2539,10 +2539,8 @@ class SomersaultSID(IntEnum):
25392539
oid=None,
25402540
short_name="annoyed_chart",
25412541
long_name=None,
2542-
description=Description(
2543-
"<p>State chart for a day where the ECU is grumpy</p>",
2544-
external_docs=[],
2545-
text_identifier=None),
2542+
description=Description.from_string(
2543+
"<p>State chart for a day where the ECU is grumpy</p>"),
25462544
states=NamedItemList([
25472545
State(
25482546
odx_id=OdxLinkId("charts.annoyed.states.in_bed", doc_frags),
@@ -2642,10 +2640,8 @@ class SomersaultSID(IntEnum):
26422640
oid=None,
26432641
short_name="angry_chart",
26442642
long_name=None,
2645-
description=Description(
2646-
"<p>State chart for a day where the ECU has a hissy fit</p>",
2647-
external_docs=[],
2648-
text_identifier=None),
2643+
description=Description.from_string(
2644+
"<p>State chart for a day where the ECU has a hissy fit</p>"),
26492645
states=NamedItemList([
26502646
State(
26512647
odx_id=OdxLinkId("charts.angry.states.in_bed", doc_frags),

odxtools/additionalaudience.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .utils import dataclass_fields_asdict
1111

1212

13-
@dataclass
13+
@dataclass(kw_only=True)
1414
class AdditionalAudience(IdentifiableElement):
1515
"""
1616
Corresponds to ADDITIONAL-AUDIENCE.

odxtools/admindata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .snrefcontext import SnRefContext
1111

1212

13-
@dataclass
13+
@dataclass(kw_only=True)
1414
class AdminData:
1515
language: str | None
1616
company_doc_infos: list[CompanyDocInfo]

odxtools/audience.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .snrefcontext import SnRefContext
1212

1313

14-
@dataclass
14+
@dataclass(kw_only=True)
1515
class Audience:
1616
enabled_audience_refs: list[OdxLinkRef]
1717
disabled_audience_refs: list[OdxLinkRef]

odxtools/basecomparam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .utils import dataclass_fields_asdict
1414

1515

16-
@dataclass
16+
@dataclass(kw_only=True)
1717
class BaseComparam(IdentifiableElement):
1818
param_class: str
1919
cptype: StandardizationLevel

odxtools/basevariantpattern.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .variantpattern import VariantPattern
1212

1313

14-
@dataclass
14+
@dataclass(kw_only=True)
1515
class BaseVariantPattern(VariantPattern):
1616
"""Base variant patterns are variant patterns used to identify the
1717
base variant of an ECU.

odxtools/basicstructure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from .utils import dataclass_fields_asdict
2424

2525

26-
@dataclass
26+
@dataclass(kw_only=True)
2727
class BasicStructure(ComplexDop):
2828
"""Base class for structure-like objects
2929

odxtools/commrelation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .snrefcontext import SnRefContext
1616

1717

18-
@dataclass
18+
@dataclass(kw_only=True)
1919
class CommRelation:
2020
description: Description | None
2121
relation_type: str

odxtools/companydata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .utils import dataclass_fields_asdict
1515

1616

17-
@dataclass
17+
@dataclass(kw_only=True)
1818
class CompanyData(IdentifiableElement):
1919
roles: list[str]
2020
team_members: NamedItemList[TeamMember]

odxtools/companydocinfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .teammember import TeamMember
1313

1414

15-
@dataclass
15+
@dataclass(kw_only=True)
1616
class CompanyDocInfo:
1717
company_data_ref: OdxLinkRef
1818
team_member_ref: OdxLinkRef | None

odxtools/companyrevisioninfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .snrefcontext import SnRefContext
1111

1212

13-
@dataclass
13+
@dataclass(kw_only=True)
1414
class CompanyRevisionInfo:
1515
company_data_ref: OdxLinkRef
1616
revision_label: str | None

odxtools/companyspecificinfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .specialdatagroup import SpecialDataGroup
1111

1212

13-
@dataclass
13+
@dataclass(kw_only=True)
1414
class CompanySpecificInfo:
1515
related_docs: list[RelatedDoc]
1616
sdgs: list[SpecialDataGroup]

odxtools/comparam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .utils import dataclass_fields_asdict
1414

1515

16-
@dataclass
16+
@dataclass(kw_only=True)
1717
class Comparam(BaseComparam):
1818
physical_default_value_raw: str
1919
dop_ref: OdxLinkRef

odxtools/comparaminstance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .snrefcontext import SnRefContext
1515

1616

17-
@dataclass
17+
@dataclass(kw_only=True)
1818
class ComparamInstance:
1919
"""
2020
This class represents a communication parameter.

odxtools/comparamspec.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .database import Database
1616

1717

18-
@dataclass
18+
@dataclass(kw_only=True)
1919
class ComparamSpec(OdxCategory):
2020

2121
prot_stacks: NamedItemList[ProtStack]

odxtools/comparamsubset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from .database import Database
1919

2020

21-
@dataclass
21+
@dataclass(kw_only=True)
2222
class ComparamSubset(OdxCategory):
2323
comparams: NamedItemList[Comparam]
2424
complex_comparams: NamedItemList[ComplexComparam]

odxtools/complexcomparam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def create_complex_value_from_et(et_element: ElementTree.Element) -> ComplexValu
2424
return result
2525

2626

27-
@dataclass
27+
@dataclass(kw_only=True)
2828
class ComplexComparam(BaseComparam):
2929
subparams: NamedItemList[BaseComparam]
3030
physical_default_value: ComplexValue | None

odxtools/complexdop.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .dopbase import DopBase
55

66

7-
@dataclass
7+
@dataclass(kw_only=True)
88
class ComplexDop(DopBase):
99
"""Base class for all complex data object properties.
1010

odxtools/compumethods/compucodecompumethod.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .compumethod import CompuMethod
1313

1414

15-
@dataclass
15+
@dataclass(kw_only=True)
1616
class CompuCodeCompuMethod(CompuMethod):
1717
"""A compu method specifies the tranfer functions using Java bytecode
1818

odxtools/compumethods/compuconst.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ..odxtypes import AtomicOdxType, DataType
66

77

8-
@dataclass
8+
@dataclass(kw_only=True)
99
class CompuConst:
1010
v: str | None
1111
vt: str | None

odxtools/compumethods/compudefaultvalue.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .compuinversevalue import CompuInverseValue
99

1010

11-
@dataclass
11+
@dataclass(kw_only=True)
1212
class CompuDefaultValue(CompuConst):
1313
compu_inverse_value: CompuInverseValue | None
1414

odxtools/compumethods/compuinternaltophys.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .compuscale import CompuScale
1313

1414

15-
@dataclass
15+
@dataclass(kw_only=True)
1616
class CompuInternalToPhys:
1717
compu_scales: list[CompuScale]
1818
prog_code: ProgCode | None

odxtools/compumethods/compumethod.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .compuphystointernal import CompuPhysToInternal
1414

1515

16-
@dataclass
16+
@dataclass(kw_only=True)
1717
class CompuMethod:
1818
"""A compu method translates between the internal representation
1919
of a value and their physical representation.

odxtools/compumethods/compuphystointernal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .compuscale import CompuScale
1313

1414

15-
@dataclass
15+
@dataclass(kw_only=True)
1616
class CompuPhysToInternal:
1717
compu_scales: list[CompuScale]
1818
prog_code: ProgCode | None

odxtools/compumethods/compurationalcoeffs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ..odxtypes import DataType
99

1010

11-
@dataclass
11+
@dataclass(kw_only=True)
1212
class CompuRationalCoeffs:
1313
value_type: DataType
1414

odxtools/compumethods/compuscale.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .limit import Limit
1212

1313

14-
@dataclass
14+
@dataclass(kw_only=True)
1515
class CompuScale:
1616
"""A COMPU-SCALE represents one value range of a COMPU-METHOD.
1717
"""

odxtools/compumethods/identicalcompumethod.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .compumethod import CompuMethod
1010

1111

12-
@dataclass
12+
@dataclass(kw_only=True)
1313
class IdenticalCompuMethod(CompuMethod):
1414
"""Identical compu methods just pass through the internal value.
1515

odxtools/compumethods/limit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .intervaltype import IntervalType
1010

1111

12-
@dataclass
12+
@dataclass(kw_only=True)
1313
class Limit:
1414
value_raw: str | None
1515
value_type: DataType | None

odxtools/compumethods/linearcompumethod.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .linearsegment import LinearSegment
1313

1414

15-
@dataclass
15+
@dataclass(kw_only=True)
1616
class LinearCompuMethod(CompuMethod):
1717
"""A compu method which does linear interpoation
1818

odxtools/compumethods/linearsegment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .limit import Limit
88

99

10-
@dataclass
10+
@dataclass(kw_only=True)
1111
class LinearSegment:
1212
"""Helper class to represent a segment of a piecewise-linear interpolation.
1313

odxtools/compumethods/ratfunccompumethod.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .ratfuncsegment import RatFuncSegment
1313

1414

15-
@dataclass
15+
@dataclass(kw_only=True)
1616
class RatFuncCompuMethod(CompuMethod):
1717
"""A compu method using a rational function
1818

odxtools/compumethods/ratfuncsegment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .limit import Limit
88

99

10-
@dataclass
10+
@dataclass(kw_only=True)
1111
class RatFuncSegment:
1212
"""Helper class to represent a segment of a piecewise rational function.
1313
"""

odxtools/compumethods/scalelinearcompumethod.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .linearsegment import LinearSegment
1414

1515

16-
@dataclass
16+
@dataclass(kw_only=True)
1717
class ScaleLinearCompuMethod(CompuMethod):
1818
"""A piecewise linear compu method which may feature discontinuities.
1919

odxtools/compumethods/scaleratfunccompumethod.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .ratfuncsegment import RatFuncSegment
1313

1414

15-
@dataclass
15+
@dataclass(kw_only=True)
1616
class ScaleRatFuncCompuMethod(CompuMethod):
1717
"""A compu method using a piecewise rational function
1818

odxtools/compumethods/tabintpcompumethod.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .limit import Limit
1313

1414

15-
@dataclass
15+
@dataclass(kw_only=True)
1616
class TabIntpCompuMethod(CompuMethod):
1717
"""A table-based interpolated compu method provides a continuous
1818
transfer function based on piecewise linear interpolation.

odxtools/compumethods/texttablecompumethod.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .compuscale import CompuScale
1313

1414

15-
@dataclass
15+
@dataclass(kw_only=True)
1616
class TexttableCompuMethod(CompuMethod):
1717
"""Text table compute methods translate numbers to human readable
1818
textual descriptions.

odxtools/dataobjectproperty.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from .utils import dataclass_fields_asdict
2222

2323

24-
@dataclass
24+
@dataclass(kw_only=True)
2525
class DataObjectProperty(DopBase):
2626
"""This class represents a DATA-OBJECT-PROP.
2727

odxtools/description.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .odxdoccontext import OdxDocContext
88

99

10-
@dataclass
10+
@dataclass(kw_only=True)
1111
class Description:
1212
text: str
1313
external_docs: list[ExternalDoc]

odxtools/determinenumberofitems.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .snrefcontext import SnRefContext
1111

1212

13-
@dataclass
13+
@dataclass(kw_only=True)
1414
class DetermineNumberOfItems:
1515
"""
1616
The object that determines the number of items of dynamic fields

odxtools/diagcodedtype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
]
2222

2323

24-
@dataclass
24+
@dataclass(kw_only=True)
2525
class DiagCodedType:
2626
base_type_encoding: Encoding | None
2727
base_data_type: DataType

odxtools/diagcomm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from .diaglayers.protocol import Protocol
2727

2828

29-
@dataclass
29+
@dataclass(kw_only=True)
3030
class DiagComm(IdentifiableElement):
3131
"""Representation of a diagnostic communication object.
3232

odxtools/diagdatadictionaryspec.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from .unitspec import UnitSpec
2626

2727

28-
@dataclass
28+
@dataclass(kw_only=True)
2929
class DiagDataDictionarySpec:
3030
admin_data: AdminData | None
3131
dtc_dops: NamedItemList[DtcDop]

0 commit comments

Comments
 (0)