• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SPF-OST / pytrnsys_gui / 11576810878

29 Oct 2024 03:09PM UTC coverage: 67.508% (-0.08%) from 67.591%
11576810878

push

github

web-flow
Merge pull request #564 from SPF-OST/560-black-change-line-length-to-pep8-standard-of-79-and-check-ci-reaction

changed line length in black to 79

1054 of 1475 new or added lines in 174 files covered. (71.46%)

150 existing lines in 74 files now uncovered.

10399 of 15404 relevant lines covered (67.51%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.83
/trnsysGUI/blockItemModel.py
1
import dataclasses as _dc
1✔
2
import typing as _tp
1✔
3
import uuid as _uuid
1✔
4

5
import dataclasses_jsonschema as _dcj
1✔
6

7
import pytrnsys.utils.serialization as _ser
1✔
8
import trnsysGUI.serialization as _gser
1✔
9

10

11
@_dc.dataclass
1✔
12
class BlockItemModelVersion0(
1✔
13
    _ser.UpgradableJsonSchemaMixinVersion0, _gser.RequiredDecoderFieldsMixin
14
):  # pylint: disable=too-many-instance-attributes
15
    BlockPosition: _tp.Tuple[float, float]  # pylint: disable=invalid-name
1✔
16
    ID: int  # pylint: disable=invalid-name
1✔
17
    trnsysID: int
1✔
18
    PortsIDIn: _tp.List[int]  # pylint: disable=invalid-name
1✔
19
    PortsIDOut: _tp.List[int]  # pylint: disable=invalid-name
1✔
20
    FlippedH: bool  # pylint: disable=invalid-name
1✔
21
    FlippedV: bool  # pylint: disable=invalid-name
1✔
22
    RotationN: int  # pylint: disable=invalid-name
1✔
23
    GroupName: str  # pylint: disable=invalid-name
1✔
24

25
    @classmethod
1✔
26
    def getVersion(cls) -> _uuid.UUID:
1✔
27
        return _uuid.UUID("b87a3360-eaa7-48f3-9bed-d01224727cbe")
1✔
28

29

30
@_dc.dataclass
1✔
31
class BlockItemModelVersion1(
1✔
32
    _ser.UpgradableJsonSchemaMixin, _gser.RequiredDecoderFieldsMixin
33
):  # pylint: disable=too-many-instance-attributes
34
    blockPosition: _tp.Tuple[float, float]
1✔
35
    Id: int  # pylint: disable=invalid-name
1✔
36
    trnsysId: int
1✔
37
    portsIdsIn: _tp.List[int]
1✔
38
    portsIdsOut: _tp.List[int]
1✔
39
    flippedH: bool
1✔
40
    flippedV: bool
1✔
41
    rotationN: int
1✔
42

43
    @classmethod
1✔
44
    def getSupersededClass(
1✔
45
        cls,
46
    ) -> _tp.Type[_ser.UpgradableJsonSchemaMixinVersion0]:
47
        return BlockItemModelVersion0
1✔
48

49
    @classmethod
1✔
50
    def upgrade(cls, superseded: BlockItemModelVersion0) -> "BlockItemModelVersion1":  # type: ignore[override]
1✔
51

52
        return BlockItemModelVersion1(
×
53
            superseded.BlockName,
54
            superseded.BlockDisplayName,
55
            superseded.BlockPosition,
56
            superseded.ID,
57
            superseded.trnsysID,
58
            superseded.PortsIDIn,
59
            superseded.PortsIDOut,
60
            superseded.FlippedH,
61
            superseded.FlippedV,
62
            superseded.RotationN,
63
        )
64

65
    @classmethod
1✔
66
    def getVersion(cls) -> _uuid.UUID:
1✔
67
        return _uuid.UUID("bbc03f36-d1a1-4d97-a9c0-d212ea3a0203")
1✔
68

69

70
@_dc.dataclass
1✔
71
class BlockItemModel(
1✔
72
    _gser.BlockItemUpgradableJsonSchemaMixin, _gser.RequiredDecoderFieldsMixin
73
):  # pylint: disable=too-many-instance-attributes
74
    blockPosition: _tp.Tuple[float, float]
1✔
75
    trnsysId: int
1✔
76
    portsIdsIn: _tp.List[int]
1✔
77
    portsIdsOut: _tp.List[int]
1✔
78
    flippedH: bool
1✔
79
    flippedV: bool
1✔
80
    rotationN: int
1✔
81

82
    @classmethod
1✔
83
    def getSupersededClass(
1✔
84
        cls,
85
    ) -> _tp.Type[_ser.UpgradableJsonSchemaMixinVersion0]:
86
        return BlockItemModelVersion1
1✔
87

88
    @classmethod
1✔
89
    def upgrade(cls, superseded: BlockItemModelVersion1) -> "BlockItemModel":  # type: ignore[override]
1✔
90

91
        return BlockItemModel(
1✔
92
            superseded.BlockName,
93
            superseded.BlockDisplayName,
94
            superseded.blockPosition,
95
            superseded.trnsysId,
96
            superseded.portsIdsIn,
97
            superseded.portsIdsOut,
98
            superseded.flippedH,
99
            superseded.flippedV,
100
            superseded.rotationN,
101
        )
102

103
    @classmethod
1✔
104
    def getVersion(cls) -> _uuid.UUID:
1✔
105
        return _uuid.UUID("e8cfde2f-8239-4338-a5f0-63a7abb93900")
1✔
106

107

108
@_dc.dataclass
1✔
109
class BlockItemBaseModelVersion0(
1✔
110
    _ser.UpgradableJsonSchemaMixinVersion0
111
):  # pylint: disable=too-many-instance-attributes
112
    blockPosition: _tp.Tuple[float, float]
1✔
113
    Id: int  # pylint: disable=invalid-name,duplicate-code # 1
1✔
114
    trnsysId: int
1✔
115
    flippedH: bool
1✔
116
    flippedV: bool
1✔
117
    rotationN: int
1✔
118

119
    @classmethod
1✔
120
    @_tp.override
1✔
121
    def getVersion(cls) -> _uuid.UUID:
1✔
122
        return _uuid.UUID("4f64dfcd-a0cf-45fd-a788-ff774c5b608f")
1✔
123

124

125
@_dc.dataclass
1✔
126
class BlockItemBaseModel(_ser.UpgradableJsonSchemaMixin):
1✔
127
    blockPosition: _tp.Tuple[float, float]
1✔
128
    trnsysId: int
1✔
129
    flippedH: bool
1✔
130
    flippedV: bool
1✔
131
    rotationN: int
1✔
132

133
    @classmethod
1✔
134
    def getSupersededClass(
1✔
135
        cls,
136
    ) -> _tp.Type[_ser.UpgradableJsonSchemaMixinVersion0]:
137
        return BlockItemBaseModelVersion0
1✔
138

139
    @classmethod
1✔
140
    def upgrade(
1✔
141
        cls, superseded: _ser.UpgradableJsonSchemaMixinVersion0
142
    ) -> "BlockItemBaseModel":
UNCOV
143
        assert isinstance(superseded, BlockItemBaseModelVersion0)
×
144

145
        blockItemModel = createBlockItemBaseModelFromLegacyModel(superseded)
×
146

147
        return blockItemModel
×
148

149
    @classmethod
1✔
150
    @_tp.override
1✔
151
    def getVersion(cls) -> _uuid.UUID:
1✔
152
        return _uuid.UUID("7b792574-5fa6-4c3e-b2e3-7e4eb71d7746")
1✔
153

154

155
class BlockItemLegacyModelProtocol(_tp.Protocol):
1✔
156
    blockPosition: _tp.Tuple[float, float]
1✔
157
    trnsysId: int
1✔
158
    flippedH: bool
1✔
159
    flippedV: bool
1✔
160
    rotationN: int
1✔
161

162

163
def createBlockItemBaseModelFromLegacyModel(
1✔
164
    superseded: BlockItemLegacyModelProtocol,
165
) -> BlockItemBaseModel:
166
    return BlockItemBaseModel(
1✔
167
        superseded.blockPosition,
168
        superseded.trnsysId,
169
        superseded.flippedH,
170
        superseded.flippedV,
171
        superseded.rotationN,
172
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc