Skip to content

Commit 1f102fe

Browse files
woshilapinKhoyo
authored andcommitted
osrd_schemas: add ruff
Signed-off-by: Jean SIMARD <[email protected]>
1 parent 6f60b79 commit 1f102fe

11 files changed

+468
-416
lines changed

.github/workflows/build.yml

+3-15
Original file line numberDiff line numberDiff line change
@@ -395,23 +395,11 @@ jobs:
395395
run: |
396396
cd python/osrd_schemas
397397
poetry install
398-
- name: Flake8
398+
- name: Ruff
399399
run: |
400400
cd python/osrd_schemas
401-
poetry run pflake8 --config ./pyproject.toml --output-file flake8.xml --format junit-xml
402-
- name: Publish flake8 report
403-
uses: mikepenz/action-junit-report@v5
404-
if: failure()
405-
with:
406-
report_paths: flake8.xml
407-
- name: Black
408-
run: |
409-
cd python/osrd_schemas
410-
poetry run black . --check
411-
- name: Isort
412-
run: |
413-
cd python/osrd_schemas
414-
poetry run isort . --check
401+
poetry run ruff check
402+
poetry run ruff format --check
415403
- name: Pytype
416404
run: |
417405
cd python/osrd_schemas

python/osrd_schemas/osrd_schemas/external_generated_inputs.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ class ElectricalProfile(BaseModel):
1010
There should be one value per power class, on every electrified track."""
1111

1212
value: str = Field(description="Category of power loss along the range")
13-
power_class: str = Field(description="Category of rolling stock power usage this profile applies to")
14-
track_ranges: List[TrackRange] = Field(description="List of locations where this profile is applied")
13+
power_class: str = Field(
14+
description="Category of rolling stock power usage this profile applies to"
15+
)
16+
track_ranges: List[TrackRange] = Field(
17+
description="List of locations where this profile is applied"
18+
)
1519

1620

1721
class ElectricalProfileSet(BaseModel):
1822
"""This class is used to represent a set of electrical profiles, to use in simulation along an infrastructure."""
1923

20-
levels: List[ElectricalProfile] = Field(description="The list of electrical profiles")
24+
levels: List[ElectricalProfile] = Field(
25+
description="The list of electrical profiles"
26+
)
2127
level_order: Dict[str, List[str]] = Field(
2228
description="""A mapping from electrification modes to the electrical profile levels
2329
in decreasing order of magnitude"""

python/osrd_schemas/osrd_schemas/generated.py

+30-10
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,28 @@ class ObjectReference(BaseModel):
1313
# TRAITS
1414
class InfraErrorTrait(BaseModel):
1515
is_warning: Literal[False] = Field(default=False)
16-
obj_id: str = Field(description="Identifier of the object that caused the error", max_length=255)
17-
obj_type: str = Field(description="Type of the object that caused the error", max_length=32)
18-
field: str = Field(description="Field of the object that caused the error", max_length=255)
16+
obj_id: str = Field(
17+
description="Identifier of the object that caused the error", max_length=255
18+
)
19+
obj_type: str = Field(
20+
description="Type of the object that caused the error", max_length=32
21+
)
22+
field: str = Field(
23+
description="Field of the object that caused the error", max_length=255
24+
)
1925

2026

2127
class InfraWarningTrait(BaseModel):
2228
is_warning: Literal[True] = Field(default=True)
23-
obj_id: str = Field(description="Identifier of the object that caused the warning", max_length=255)
24-
obj_type: str = Field(description="Type of the object that caused the warning", max_length=32)
25-
field: str = Field(description="Field of the object that caused the warning", max_length=255)
29+
obj_id: str = Field(
30+
description="Identifier of the object that caused the warning", max_length=255
31+
)
32+
obj_type: str = Field(
33+
description="Type of the object that caused the warning", max_length=32
34+
)
35+
field: str = Field(
36+
description="Field of the object that caused the warning", max_length=255
37+
)
2638

2739

2840
# Errors
@@ -53,7 +65,9 @@ class InvalidRoute(InfraErrorTrait):
5365

5466

5567
class NodeEndpointsNotUnique(InfraErrorTrait):
56-
error_type: Literal["node_endpoints_not_unique"] = Field(default="node_endpoints_not_unique")
68+
error_type: Literal["node_endpoints_not_unique"] = Field(
69+
default="node_endpoints_not_unique"
70+
)
5771

5872

5973
class UnknownPortName(InfraErrorTrait):
@@ -94,16 +108,22 @@ class MissingBufferStop(InfraWarningTrait):
94108

95109

96110
class OddBufferStopLocation(InfraWarningTrait):
97-
error_type: Literal["odd_buffer_stop_location"] = Field(default="odd_buffer_stop_location")
111+
error_type: Literal["odd_buffer_stop_location"] = Field(
112+
default="odd_buffer_stop_location"
113+
)
98114

99115

100116
class OverlappingSpeedSections(InfraWarningTrait):
101-
error_type: Literal["overlapping_speed_sections"] = Field(default="overlapping_speed_sections")
117+
error_type: Literal["overlapping_speed_sections"] = Field(
118+
default="overlapping_speed_sections"
119+
)
102120
reference: ObjectReference
103121

104122

105123
class OverlappingElectrifications(InfraWarningTrait):
106-
error_type: Literal["overlapping_electrifications"] = Field(default="overlapping_electrifications")
124+
error_type: Literal["overlapping_electrifications"] = Field(
125+
default="overlapping_electrifications"
126+
)
107127
reference: ObjectReference
108128

109129

0 commit comments

Comments
 (0)