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

SPF-OST / pytrnsys_gui / 11662562960

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

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

92.86
/trnsysGUI/components/plugin/specification/model.py
1
import collections.abc as _cabc
1✔
2
import typing as _tp
1✔
3

4
import pydantic as _pc
1✔
5

6
PortType = _tp.Literal["standard", "hot", "cold"]
1✔
7

8

9
def _nameMustBeCapitalized(what: str, name: str | None) -> str | None:
1✔
10
    if name is None:
1✔
11
        return None
1✔
12

13
    if name != name.capitalize():
1✔
14
        raise ValueError(f"{what} names must be capitalized.")
×
15

16
    return name
1✔
17

18

19
class Port(_pc.BaseModel):
1✔
20
    name: str | None = None
1✔
21
    position: tuple[int, int]
1✔
22
    type: PortType = "standard"
1✔
23

24
    @_pc.field_validator("name")
1✔
25
    @classmethod
1✔
26
    def nameMustBeCapitalized(cls, name: str | None) -> str | None:
1✔
27
        return _nameMustBeCapitalized(cls.__name__, name)
1✔
28

29

30
class NodeBase(_pc.BaseModel):
1✔
31
    name: str | None = None
1✔
32

33
    @_pc.field_validator("name")
1✔
34
    @classmethod
1✔
35
    def _nameMustBeCapitalized(cls, name: str | None) -> str | None:
1✔
36
        return _nameMustBeCapitalized(cls.__name__, name)
1✔
37

38

39
class Connection(NodeBase):
1✔
40
    input: Port
1✔
41
    output: Port
1✔
42

43

44
class TeePiece(NodeBase):
1✔
45
    input: Port
1✔
46
    output0: Port
1✔
47
    output1: Port
1✔
48

49
    @_pc.field_validator("name")
1✔
50
    @classmethod
1✔
51
    def _nameMustBeCapitalized(cls, name: str | None) -> str | None:
1✔
52
        return _nameMustBeCapitalized(cls.__name__, name)
×
53

54

55
class Specification(_pc.BaseModel):
1✔
56
    defaultName: str
1✔
57
    description: str
1✔
58
    connections: _cabc.Sequence[Connection] | None = None
1✔
59
    teePieces: _cabc.Sequence[TeePiece] | None = _pc.Field(
1✔
60
        alias="tee-pieces", default=None
61
    )
62
    size: tuple[int, int]
1✔
63

64
    @_pc.model_validator(mode="after")
1✔
65
    def _oneConnectionOrTeePieceMustBeGiven(self) -> _tp.Self:
1✔
66
        if not self.connections and not self.teePieces:
1✔
NEW
67
            raise ValueError(
×
68
                "At least one connection or T-piece must be specified."
69
            )
70

71
        return self
1✔
72

73
    @_pc.model_validator(mode="after")
1✔
74
    def _connectionOrTeePieceCanOmitNameOnlyIfSingle(self) -> _tp.Self:
1✔
75
        connections = self.connections or []
1✔
76
        teePieces = self.teePieces or []
1✔
77

78
        connectionsAndTeePieces = [*connections, *teePieces]
1✔
79
        hasWithoutName = any(
1✔
80
            tc for tc in connectionsAndTeePieces if not tc.name
81
        )
82
        nTeePiecesAndConnections = len(connectionsAndTeePieces)
1✔
83

84
        if hasWithoutName and nTeePiecesAndConnections > 1:
1✔
85
            raise ValueError(
×
86
                "A connection or tee piece can only not have a name if there "
87
                "is only a single tee piece or single connection."
88
            )
89

90
        return self
1✔
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