Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osrd_schemas: update to 'poetry:2.0' and use 'ruff' for linting #10724

Merged
merged 3 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install 'poetry<2.0'
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -388,28 +388,16 @@ jobs:
- name: Install dependencies
run: |
cd python/osrd_schemas
poetry install
- name: Flake8
run: |
cd python/osrd_schemas
poetry run pflake8 --config ./pyproject.toml --output-file flake8.xml --format junit-xml
- name: Publish flake8 report
uses: mikepenz/action-junit-report@v5
if: failure()
with:
report_paths: flake8.xml
- name: Black
run: |
cd python/osrd_schemas
poetry run black . --check
- name: Isort
poetry install --extras=dev
- name: Ruff
run: |
cd python/osrd_schemas
poetry run isort . --check
- name: Pytype
poetry run ruff check
poetry run ruff format --check
- name: Pyright
run: |
cd python/osrd_schemas
poetry run pytype -j auto
poetry run pyright

check_toml:
runs-on: ubuntu-latest
Expand All @@ -432,7 +420,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Install poetry
run: pipx install 'poetry<2.0'
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: "3.11"
Expand Down
55 changes: 11 additions & 44 deletions front/src/reducers/osrdconf/infra_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,9 @@
"BufferStopExtensions": {
"properties": {
"sncf": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/BufferStopSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -334,12 +331,9 @@
"DetectorExtensions": {
"properties": {
"sncf": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/DetectorSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -818,12 +812,9 @@
"NeutralSectionExtensions": {
"properties": {
"neutral_sncf": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/NeutralSectionNeutralSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -926,23 +917,17 @@
"OperationalPointExtensions": {
"properties": {
"identifier": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/OperationalPointIdentifierExtension"
},
{
"type": "null"
}
],
"default": null
},
"sncf": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/OperationalPointSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -1007,12 +992,9 @@
"OperationalPointPartExtensions": {
"properties": {
"sncf": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/OperationalPointPartSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -1303,12 +1285,9 @@
"SignalExtensions": {
"properties": {
"sncf": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/SignalSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -1463,12 +1442,9 @@
"SpeedSectionExtensions": {
"properties": {
"psl_sncf": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/SpeedSectionPslSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -1564,12 +1540,9 @@
"SwitchExtensions": {
"properties": {
"sncf": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/SwitchSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -1755,23 +1728,17 @@
"TrackSectionExtensions": {
"properties": {
"sncf": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/TrackSectionSncfExtension"
},
{
"type": "null"
}
],
"default": null
},
"source": {
"anyOf": [
"allOf": [
{
"$ref": "#/$defs/TrackSectionSourceExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down
1 change: 0 additions & 1 deletion python/osrd_schemas/.python-version

This file was deleted.

12 changes: 9 additions & 3 deletions python/osrd_schemas/osrd_schemas/external_generated_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ class ElectricalProfile(BaseModel):
There should be one value per power class, on every electrified track."""

value: str = Field(description="Category of power loss along the range")
power_class: str = Field(description="Category of rolling stock power usage this profile applies to")
track_ranges: List[TrackRange] = Field(description="List of locations where this profile is applied")
power_class: str = Field(
description="Category of rolling stock power usage this profile applies to"
)
track_ranges: List[TrackRange] = Field(
description="List of locations where this profile is applied"
)


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

levels: List[ElectricalProfile] = Field(description="The list of electrical profiles")
levels: List[ElectricalProfile] = Field(
description="The list of electrical profiles"
)
level_order: Dict[str, List[str]] = Field(
description="""A mapping from electrification modes to the electrical profile levels
in decreasing order of magnitude"""
Expand Down
40 changes: 30 additions & 10 deletions python/osrd_schemas/osrd_schemas/generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,28 @@ class ObjectReference(BaseModel):
# TRAITS
class InfraErrorTrait(BaseModel):
is_warning: Literal[False] = Field(default=False)
obj_id: str = Field(description="Identifier of the object that caused the error", max_length=255)
obj_type: str = Field(description="Type of the object that caused the error", max_length=32)
field: str = Field(description="Field of the object that caused the error", max_length=255)
obj_id: str = Field(
description="Identifier of the object that caused the error", max_length=255
)
obj_type: str = Field(
description="Type of the object that caused the error", max_length=32
)
field: str = Field(
description="Field of the object that caused the error", max_length=255
)


class InfraWarningTrait(BaseModel):
is_warning: Literal[True] = Field(default=True)
obj_id: str = Field(description="Identifier of the object that caused the warning", max_length=255)
obj_type: str = Field(description="Type of the object that caused the warning", max_length=32)
field: str = Field(description="Field of the object that caused the warning", max_length=255)
obj_id: str = Field(
description="Identifier of the object that caused the warning", max_length=255
)
obj_type: str = Field(
description="Type of the object that caused the warning", max_length=32
)
field: str = Field(
description="Field of the object that caused the warning", max_length=255
)


# Errors
Expand Down Expand Up @@ -53,7 +65,9 @@ class InvalidRoute(InfraErrorTrait):


class NodeEndpointsNotUnique(InfraErrorTrait):
error_type: Literal["node_endpoints_not_unique"] = Field(default="node_endpoints_not_unique")
error_type: Literal["node_endpoints_not_unique"] = Field(
default="node_endpoints_not_unique"
)


class UnknownPortName(InfraErrorTrait):
Expand Down Expand Up @@ -94,16 +108,22 @@ class MissingBufferStop(InfraWarningTrait):


class OddBufferStopLocation(InfraWarningTrait):
error_type: Literal["odd_buffer_stop_location"] = Field(default="odd_buffer_stop_location")
error_type: Literal["odd_buffer_stop_location"] = Field(
default="odd_buffer_stop_location"
)


class OverlappingSpeedSections(InfraWarningTrait):
error_type: Literal["overlapping_speed_sections"] = Field(default="overlapping_speed_sections")
error_type: Literal["overlapping_speed_sections"] = Field(
default="overlapping_speed_sections"
)
reference: ObjectReference


class OverlappingElectrifications(InfraWarningTrait):
error_type: Literal["overlapping_electrifications"] = Field(default="overlapping_electrifications")
error_type: Literal["overlapping_electrifications"] = Field(
default="overlapping_electrifications"
)
reference: ObjectReference


Expand Down
Loading
Loading