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

add S2 Message Union type #37

Merged
merged 18 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f5e401d
add S2 Message Union type
victorgarcia98 Mar 21, 2024
1cc8b26
Merge branch 'refs/heads/pydantic_v1' into generic-s2-message
Flix6x Dec 2, 2024
c2fede2
chore: move to Literals as Pydantic 2 does
Flix6x Dec 2, 2024
2d13d5a
chore: run `datamodel-codegen --input specification/openapi.yml --inp…
Flix6x Dec 2, 2024
1dc8bcf
Merge remote-tracking branch 'refs/remotes/origin/main' into generic-…
Flix6x Jan 15, 2025
02966c2
refactor: rename old S2Message to S2MessageComponent
Flix6x Jan 15, 2025
78ff1d3
style: pylint
Flix6x Jan 15, 2025
fd59de6
refactor: prefer S2Message over S2MessageComponent
Flix6x Jan 15, 2025
0171f5a
Revert "refactor: prefer S2Message over S2MessageComponent"
Flix6x Jan 15, 2025
87a4ca6
refactor: prefer S2Message over S2MessageComponent in s2_parser.py
Flix6x Jan 16, 2025
112e78f
fix: `src/s2python/s2_parser.py:49: error: Dict entry 8 has incompati…
Flix6x Jan 16, 2025
828309f
refactor: prefer S2Message over S2MessageComponent in s2_control_type.py
Flix6x Jan 16, 2025
82dab11
refactor: prefer S2Message over S2MessageComponent in s2_connection.py
Flix6x Jan 23, 2025
76a76ac
fix: s2_parser.py has 1 place that still requires the S2MessageComponent
Flix6x Jan 23, 2025
dc3d706
dev: change subject_message_id to message_id (did mypy find a bug? Re…
Flix6x Jan 23, 2025
f10e708
Revert "dev: change subject_message_id to message_id (did mypy find a…
Flix6x Jan 23, 2025
ad87e8b
fix: type ignore union-attr instead; underlying issue should be fixed…
Flix6x Jan 23, 2025
3f31f16
fix: linting
Flix6x Jan 23, 2025
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
12 changes: 12 additions & 0 deletions development_utilities/get_all_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import inspect
Flix6x marked this conversation as resolved.
Show resolved Hide resolved
import s2python.frbc as frbc
import s2python.common as common

from pydantic import BaseModel

all_members = inspect.getmembers(frbc) + inspect.getmembers(common)
all_members.sort(key=lambda t: t[0])

for name, member in all_members:
if inspect.isclass(member) and issubclass(member, BaseModel) and "message_type" in member.__fields__:
print(f"{name},")
4 changes: 2 additions & 2 deletions src/s2python/common/duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from s2python.generated.gen_s2 import Duration as GenDuration
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class Duration(GenDuration, S2Message["Duration"]):
class Duration(GenDuration, S2MessageComponent["Duration"]):
def to_timedelta(self) -> timedelta:
return timedelta(milliseconds=self.root)

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/handshake.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from s2python.generated.gen_s2 import Handshake as GenHandshake
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class Handshake(GenHandshake, S2Message["Handshake"]):
class Handshake(GenHandshake, S2MessageComponent["Handshake"]):
model_config = GenHandshake.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/handshake_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from s2python.generated.gen_s2 import HandshakeResponse as GenHandshakeResponse
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class HandshakeResponse(GenHandshakeResponse, S2Message["HandshakeResponse"]):
class HandshakeResponse(GenHandshakeResponse, S2MessageComponent["HandshakeResponse"]):
model_config = GenHandshakeResponse.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/instruction_status_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
)
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class InstructionStatusUpdate(GenInstructionStatusUpdate, S2Message["InstructionStatusUpdate"]):
class InstructionStatusUpdate(GenInstructionStatusUpdate, S2MessageComponent["InstructionStatusUpdate"]):
model_config = GenInstructionStatusUpdate.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/number_range.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Any

from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
from s2python.validate_values_mixin import S2MessageComponent, catch_and_convert_exceptions
from s2python.generated.gen_s2 import NumberRange as GenNumberRange


@catch_and_convert_exceptions
class NumberRange(GenNumberRange, S2Message["NumberRange"]):
class NumberRange(GenNumberRange, S2MessageComponent["NumberRange"]):
model_config = GenNumberRange.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/power_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from s2python.generated.gen_s2 import PowerForecast as GenPowerForecast
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class PowerForecast(GenPowerForecast, S2Message["PowerForecast"]):
class PowerForecast(GenPowerForecast, S2MessageComponent["PowerForecast"]):
model_config = GenPowerForecast.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/power_forecast_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from s2python.generated.gen_s2 import PowerForecastElement as GenPowerForecastElement
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)
from s2python.common.duration import Duration
from s2python.common.power_forecast_value import PowerForecastValue


@catch_and_convert_exceptions
class PowerForecastElement(GenPowerForecastElement, S2Message["PowerForecastElement"]):
class PowerForecastElement(GenPowerForecastElement, S2MessageComponent["PowerForecastElement"]):
model_config = GenPowerForecastElement.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/power_forecast_value.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from s2python.generated.gen_s2 import PowerForecastValue as GenPowerForecastValue
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class PowerForecastValue(GenPowerForecastValue, S2Message["PowerForecastValue"]):
class PowerForecastValue(GenPowerForecastValue, S2MessageComponent["PowerForecastValue"]):
model_config = GenPowerForecastValue.model_config
model_config["validate_assignment"] = True
4 changes: 2 additions & 2 deletions src/s2python/common/power_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from s2python.generated.gen_s2 import PowerMeasurement as GenPowerMeasurement
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class PowerMeasurement(GenPowerMeasurement, S2Message["PowerMeasurement"]):
class PowerMeasurement(GenPowerMeasurement, S2MessageComponent["PowerMeasurement"]):
model_config = GenPowerMeasurement.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/power_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from s2python.generated.gen_s2 import PowerRange as GenPowerRange
from s2python.validate_values_mixin import (
S2Message,
S2MessageComponent,
catch_and_convert_exceptions,
)


@catch_and_convert_exceptions
class PowerRange(GenPowerRange, S2Message["PowerRange"]):
class PowerRange(GenPowerRange, S2MessageComponent["PowerRange"]):
model_config = GenPowerRange.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/power_value.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from s2python.generated.gen_s2 import PowerValue as GenPowerValue
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class PowerValue(GenPowerValue, S2Message["PowerValue"]):
class PowerValue(GenPowerValue, S2MessageComponent["PowerValue"]):
model_config = GenPowerValue.model_config
model_config["validate_assignment"] = True
4 changes: 2 additions & 2 deletions src/s2python/common/reception_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from s2python.generated.gen_s2 import ReceptionStatus as GenReceptionStatus
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class ReceptionStatus(GenReceptionStatus, S2Message["ReceptionStatus"]):
class ReceptionStatus(GenReceptionStatus, S2MessageComponent["ReceptionStatus"]):
model_config = GenReceptionStatus.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/resource_manager_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
)
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class ResourceManagerDetails(GenResourceManagerDetails, S2Message["ResourceManagerDetails"]):
class ResourceManagerDetails(GenResourceManagerDetails, S2MessageComponent["ResourceManagerDetails"]):
model_config = GenResourceManagerDetails.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/revoke_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from s2python.generated.gen_s2 import RevokeObject as GenRevokeObject
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class RevokeObject(GenRevokeObject, S2Message["RevokeObject"]):
class RevokeObject(GenRevokeObject, S2MessageComponent["RevokeObject"]):
model_config = GenRevokeObject.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/role.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from s2python.generated.gen_s2 import Role as GenRole
from s2python.validate_values_mixin import (
S2Message,
S2MessageComponent,
catch_and_convert_exceptions,
)


@catch_and_convert_exceptions
class Role(GenRole, S2Message["Role"]):
class Role(GenRole, S2MessageComponent["Role"]):
model_config = GenRole.model_config
model_config["validate_assignment"] = True
4 changes: 2 additions & 2 deletions src/s2python/common/select_control_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from s2python.generated.gen_s2 import SelectControlType as GenSelectControlType
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class SelectControlType(GenSelectControlType, S2Message["SelectControlType"]):
class SelectControlType(GenSelectControlType, S2MessageComponent["SelectControlType"]):
model_config = GenSelectControlType.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/session_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from s2python.generated.gen_s2 import SessionRequest as GenSessionRequest
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class SessionRequest(GenSessionRequest, S2Message["SessionRequest"]):
class SessionRequest(GenSessionRequest, S2MessageComponent["SessionRequest"]):
model_config = GenSessionRequest.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from s2python.common.duration import Duration
from s2python.generated.gen_s2 import Timer as GenTimer
from s2python.validate_values_mixin import (
S2Message,
S2MessageComponent,
catch_and_convert_exceptions,
)


@catch_and_convert_exceptions
class Timer(GenTimer, S2Message["Timer"]):
class Timer(GenTimer, S2MessageComponent["Timer"]):
model_config = GenTimer.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from s2python.common.duration import Duration
from s2python.generated.gen_s2 import Transition as GenTransition
from s2python.validate_values_mixin import (
S2Message,
S2MessageComponent,
catch_and_convert_exceptions,
)


@catch_and_convert_exceptions
class Transition(GenTransition, S2Message["Transition"]):
class Transition(GenTransition, S2MessageComponent["Transition"]):
model_config = GenTransition.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/frbc/frbc_actuator_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
FRBCActuatorDescription as GenFRBCActuatorDescription,
)
from s2python.validate_values_mixin import (
S2Message,
S2MessageComponent,
catch_and_convert_exceptions,
)


@catch_and_convert_exceptions
class FRBCActuatorDescription(GenFRBCActuatorDescription, S2Message["FRBCActuatorDescription"]):
class FRBCActuatorDescription(GenFRBCActuatorDescription, S2MessageComponent["FRBCActuatorDescription"]):
model_config = GenFRBCActuatorDescription.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/frbc/frbc_actuator_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from s2python.generated.gen_s2 import FRBCActuatorStatus as GenFRBCActuatorStatus
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class FRBCActuatorStatus(GenFRBCActuatorStatus, S2Message["FRBCActuatorStatus"]):
class FRBCActuatorStatus(GenFRBCActuatorStatus, S2MessageComponent["FRBCActuatorStatus"]):
model_config = GenFRBCActuatorStatus.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/frbc/frbc_fill_level_target_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
)
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class FRBCFillLevelTargetProfile(GenFRBCFillLevelTargetProfile, S2Message["FRBCFillLevelTargetProfile"]):
class FRBCFillLevelTargetProfile(GenFRBCFillLevelTargetProfile, S2MessageComponent["FRBCFillLevelTargetProfile"]):
model_config = GenFRBCFillLevelTargetProfile.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/frbc/frbc_fill_level_target_profile_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from s2python.generated.gen_s2 import (
FRBCFillLevelTargetProfileElement as GenFRBCFillLevelTargetProfileElement,
)
from s2python.validate_values_mixin import catch_and_convert_exceptions, S2Message
from s2python.validate_values_mixin import catch_and_convert_exceptions, S2MessageComponent


@catch_and_convert_exceptions
class FRBCFillLevelTargetProfileElement(
GenFRBCFillLevelTargetProfileElement, S2Message["FRBCFillLevelTargetProfileElement"]
GenFRBCFillLevelTargetProfileElement, S2MessageComponent["FRBCFillLevelTargetProfileElement"]
):
model_config = GenFRBCFillLevelTargetProfileElement.model_config
model_config["validate_assignment"] = True
Expand Down
4 changes: 2 additions & 2 deletions src/s2python/frbc/frbc_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from s2python.generated.gen_s2 import FRBCInstruction as GenFRBCInstruction
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class FRBCInstruction(GenFRBCInstruction, S2Message["FRBCInstruction"]):
class FRBCInstruction(GenFRBCInstruction, S2MessageComponent["FRBCInstruction"]):
model_config = GenFRBCInstruction.model_config
model_config["validate_assignment"] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/frbc/frbc_leakage_behaviour.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from s2python.generated.gen_s2 import FRBCLeakageBehaviour as GenFRBCLeakageBehaviour
from s2python.validate_values_mixin import (
catch_and_convert_exceptions,
S2Message,
S2MessageComponent,
)


@catch_and_convert_exceptions
class FRBCLeakageBehaviour(GenFRBCLeakageBehaviour, S2Message["FRBCLeakageBehaviour"]):
class FRBCLeakageBehaviour(GenFRBCLeakageBehaviour, S2MessageComponent["FRBCLeakageBehaviour"]):
model_config = GenFRBCLeakageBehaviour.model_config
model_config["validate_assignment"] = True

Expand Down
Loading
Loading