diff --git a/development_utilities/get_all_messages.py b/development_utilities/get_all_messages.py new file mode 100644 index 0000000..4135eaa --- /dev/null +++ b/development_utilities/get_all_messages.py @@ -0,0 +1,12 @@ +import inspect +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},") \ No newline at end of file diff --git a/src/s2python/common/duration.py b/src/s2python/common/duration.py index 65663c0..a8f6708 100644 --- a/src/s2python/common/duration.py +++ b/src/s2python/common/duration.py @@ -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) diff --git a/src/s2python/common/handshake.py b/src/s2python/common/handshake.py index c068150..9598c95 100644 --- a/src/s2python/common/handshake.py +++ b/src/s2python/common/handshake.py @@ -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 diff --git a/src/s2python/common/handshake_response.py b/src/s2python/common/handshake_response.py index fcc2eb5..e6a9d95 100644 --- a/src/s2python/common/handshake_response.py +++ b/src/s2python/common/handshake_response.py @@ -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 diff --git a/src/s2python/common/instruction_status_update.py b/src/s2python/common/instruction_status_update.py index 5a8c45f..6420058 100644 --- a/src/s2python/common/instruction_status_update.py +++ b/src/s2python/common/instruction_status_update.py @@ -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 diff --git a/src/s2python/common/number_range.py b/src/s2python/common/number_range.py index 070b74a..40525a2 100644 --- a/src/s2python/common/number_range.py +++ b/src/s2python/common/number_range.py @@ -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 diff --git a/src/s2python/common/power_forecast.py b/src/s2python/common/power_forecast.py index 31c595d..dff4fe2 100644 --- a/src/s2python/common/power_forecast.py +++ b/src/s2python/common/power_forecast.py @@ -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 diff --git a/src/s2python/common/power_forecast_element.py b/src/s2python/common/power_forecast_element.py index 10460f7..5f1626d 100644 --- a/src/s2python/common/power_forecast_element.py +++ b/src/s2python/common/power_forecast_element.py @@ -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 diff --git a/src/s2python/common/power_forecast_value.py b/src/s2python/common/power_forecast_value.py index 3ee2cc3..296b35e 100644 --- a/src/s2python/common/power_forecast_value.py +++ b/src/s2python/common/power_forecast_value.py @@ -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 diff --git a/src/s2python/common/power_measurement.py b/src/s2python/common/power_measurement.py index 27896c9..b4c1749 100644 --- a/src/s2python/common/power_measurement.py +++ b/src/s2python/common/power_measurement.py @@ -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 diff --git a/src/s2python/common/power_range.py b/src/s2python/common/power_range.py index 4ca1ec8..dc0e0bf 100644 --- a/src/s2python/common/power_range.py +++ b/src/s2python/common/power_range.py @@ -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 diff --git a/src/s2python/common/power_value.py b/src/s2python/common/power_value.py index c623627..a210bf2 100644 --- a/src/s2python/common/power_value.py +++ b/src/s2python/common/power_value.py @@ -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 diff --git a/src/s2python/common/reception_status.py b/src/s2python/common/reception_status.py index a759897..edae59c 100644 --- a/src/s2python/common/reception_status.py +++ b/src/s2python/common/reception_status.py @@ -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 diff --git a/src/s2python/common/resource_manager_details.py b/src/s2python/common/resource_manager_details.py index 82ce844..35b00b6 100644 --- a/src/s2python/common/resource_manager_details.py +++ b/src/s2python/common/resource_manager_details.py @@ -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 diff --git a/src/s2python/common/revoke_object.py b/src/s2python/common/revoke_object.py index d133c79..250628b 100644 --- a/src/s2python/common/revoke_object.py +++ b/src/s2python/common/revoke_object.py @@ -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 diff --git a/src/s2python/common/role.py b/src/s2python/common/role.py index 4a3d3ef..293983c 100644 --- a/src/s2python/common/role.py +++ b/src/s2python/common/role.py @@ -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 diff --git a/src/s2python/common/select_control_type.py b/src/s2python/common/select_control_type.py index 5f02954..675fcc8 100644 --- a/src/s2python/common/select_control_type.py +++ b/src/s2python/common/select_control_type.py @@ -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 diff --git a/src/s2python/common/session_request.py b/src/s2python/common/session_request.py index f962427..907eb67 100644 --- a/src/s2python/common/session_request.py +++ b/src/s2python/common/session_request.py @@ -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 diff --git a/src/s2python/common/timer.py b/src/s2python/common/timer.py index 3811082..e4f313e 100644 --- a/src/s2python/common/timer.py +++ b/src/s2python/common/timer.py @@ -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 diff --git a/src/s2python/common/transition.py b/src/s2python/common/transition.py index e1e1a25..2c10a06 100644 --- a/src/s2python/common/transition.py +++ b/src/s2python/common/transition.py @@ -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 diff --git a/src/s2python/frbc/frbc_actuator_description.py b/src/s2python/frbc/frbc_actuator_description.py index 08afce6..eee1132 100644 --- a/src/s2python/frbc/frbc_actuator_description.py +++ b/src/s2python/frbc/frbc_actuator_description.py @@ -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 diff --git a/src/s2python/frbc/frbc_actuator_status.py b/src/s2python/frbc/frbc_actuator_status.py index 585a23d..a9d6072 100644 --- a/src/s2python/frbc/frbc_actuator_status.py +++ b/src/s2python/frbc/frbc_actuator_status.py @@ -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 diff --git a/src/s2python/frbc/frbc_fill_level_target_profile.py b/src/s2python/frbc/frbc_fill_level_target_profile.py index 38ef83b..5232172 100644 --- a/src/s2python/frbc/frbc_fill_level_target_profile.py +++ b/src/s2python/frbc/frbc_fill_level_target_profile.py @@ -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 diff --git a/src/s2python/frbc/frbc_fill_level_target_profile_element.py b/src/s2python/frbc/frbc_fill_level_target_profile_element.py index cdb7d84..ab32ef5 100644 --- a/src/s2python/frbc/frbc_fill_level_target_profile_element.py +++ b/src/s2python/frbc/frbc_fill_level_target_profile_element.py @@ -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 diff --git a/src/s2python/frbc/frbc_instruction.py b/src/s2python/frbc/frbc_instruction.py index 584cfba..ca465f6 100644 --- a/src/s2python/frbc/frbc_instruction.py +++ b/src/s2python/frbc/frbc_instruction.py @@ -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 diff --git a/src/s2python/frbc/frbc_leakage_behaviour.py b/src/s2python/frbc/frbc_leakage_behaviour.py index fda7d3b..29ca901 100644 --- a/src/s2python/frbc/frbc_leakage_behaviour.py +++ b/src/s2python/frbc/frbc_leakage_behaviour.py @@ -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 diff --git a/src/s2python/frbc/frbc_leakage_behaviour_element.py b/src/s2python/frbc/frbc_leakage_behaviour_element.py index b9ca2eb..103abe9 100644 --- a/src/s2python/frbc/frbc_leakage_behaviour_element.py +++ b/src/s2python/frbc/frbc_leakage_behaviour_element.py @@ -5,12 +5,12 @@ from s2python.common import NumberRange from s2python.generated.gen_s2 import FRBCLeakageBehaviourElement as GenFRBCLeakageBehaviourElement -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 FRBCLeakageBehaviourElement( - GenFRBCLeakageBehaviourElement, S2Message["FRBCLeakageBehaviourElement"] + GenFRBCLeakageBehaviourElement, S2MessageComponent["FRBCLeakageBehaviourElement"] ): model_config = GenFRBCLeakageBehaviourElement.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/frbc/frbc_operation_mode.py b/src/s2python/frbc/frbc_operation_mode.py index c6758ad..a37d0d9 100644 --- a/src/s2python/frbc/frbc_operation_mode.py +++ b/src/s2python/frbc/frbc_operation_mode.py @@ -9,14 +9,14 @@ from s2python.frbc.frbc_operation_mode_element import FRBCOperationModeElement from s2python.generated.gen_s2 import FRBCOperationMode as GenFRBCOperationMode from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) from s2python.utils import pairwise @catch_and_convert_exceptions -class FRBCOperationMode(GenFRBCOperationMode, S2Message["FRBCOperationMode"]): +class FRBCOperationMode(GenFRBCOperationMode, S2MessageComponent["FRBCOperationMode"]): model_config = GenFRBCOperationMode.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/frbc/frbc_operation_mode_element.py b/src/s2python/frbc/frbc_operation_mode_element.py index d154d11..55f18b3 100644 --- a/src/s2python/frbc/frbc_operation_mode_element.py +++ b/src/s2python/frbc/frbc_operation_mode_element.py @@ -5,13 +5,13 @@ FRBCOperationModeElement as GenFRBCOperationModeElement, ) from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) @catch_and_convert_exceptions -class FRBCOperationModeElement(GenFRBCOperationModeElement, S2Message["FRBCOperationModeElement"]): +class FRBCOperationModeElement(GenFRBCOperationModeElement, S2MessageComponent["FRBCOperationModeElement"]): model_config = GenFRBCOperationModeElement.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/frbc/frbc_storage_description.py b/src/s2python/frbc/frbc_storage_description.py index eb141b8..3b2c985 100644 --- a/src/s2python/frbc/frbc_storage_description.py +++ b/src/s2python/frbc/frbc_storage_description.py @@ -4,12 +4,12 @@ ) from s2python.validate_values_mixin import ( catch_and_convert_exceptions, - S2Message, + S2MessageComponent, ) @catch_and_convert_exceptions -class FRBCStorageDescription(GenFRBCStorageDescription, S2Message["FRBCStorageDescription"]): +class FRBCStorageDescription(GenFRBCStorageDescription, S2MessageComponent["FRBCStorageDescription"]): model_config = GenFRBCStorageDescription.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/frbc/frbc_storage_status.py b/src/s2python/frbc/frbc_storage_status.py index 7940b79..d0ce3e1 100644 --- a/src/s2python/frbc/frbc_storage_status.py +++ b/src/s2python/frbc/frbc_storage_status.py @@ -3,12 +3,12 @@ from s2python.generated.gen_s2 import FRBCStorageStatus as GenFRBCStorageStatus from s2python.validate_values_mixin import ( catch_and_convert_exceptions, - S2Message, + S2MessageComponent, ) @catch_and_convert_exceptions -class FRBCStorageStatus(GenFRBCStorageStatus, S2Message["FRBCStorageStatus"]): +class FRBCStorageStatus(GenFRBCStorageStatus, S2MessageComponent["FRBCStorageStatus"]): model_config = GenFRBCStorageStatus.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/frbc/frbc_system_description.py b/src/s2python/frbc/frbc_system_description.py index 2eb5899..4497d44 100644 --- a/src/s2python/frbc/frbc_system_description.py +++ b/src/s2python/frbc/frbc_system_description.py @@ -4,14 +4,14 @@ from s2python.generated.gen_s2 import FRBCSystemDescription as GenFRBCSystemDescription from s2python.validate_values_mixin import ( catch_and_convert_exceptions, - S2Message, + S2MessageComponent, ) from s2python.frbc.frbc_actuator_description import FRBCActuatorDescription from s2python.frbc.frbc_storage_description import FRBCStorageDescription @catch_and_convert_exceptions -class FRBCSystemDescription(GenFRBCSystemDescription, S2Message["FRBCSystemDescription"]): +class FRBCSystemDescription(GenFRBCSystemDescription, S2MessageComponent["FRBCSystemDescription"]): model_config = GenFRBCSystemDescription.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/frbc/frbc_timer_status.py b/src/s2python/frbc/frbc_timer_status.py index 80c86d6..02a6d22 100644 --- a/src/s2python/frbc/frbc_timer_status.py +++ b/src/s2python/frbc/frbc_timer_status.py @@ -3,12 +3,12 @@ from s2python.generated.gen_s2 import FRBCTimerStatus as GenFRBCTimerStatus from s2python.validate_values_mixin import ( catch_and_convert_exceptions, - S2Message, + S2MessageComponent, ) @catch_and_convert_exceptions -class FRBCTimerStatus(GenFRBCTimerStatus, S2Message["FRBCTimerStatus"]): +class FRBCTimerStatus(GenFRBCTimerStatus, S2MessageComponent["FRBCTimerStatus"]): model_config = GenFRBCTimerStatus.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/frbc/frbc_usage_forecast.py b/src/s2python/frbc/frbc_usage_forecast.py index f71fda4..bab3297 100644 --- a/src/s2python/frbc/frbc_usage_forecast.py +++ b/src/s2python/frbc/frbc_usage_forecast.py @@ -4,13 +4,13 @@ from s2python.generated.gen_s2 import FRBCUsageForecast as GenFRBCUsageForecast from s2python.validate_values_mixin import ( catch_and_convert_exceptions, - S2Message, + S2MessageComponent, ) from s2python.frbc.frbc_usage_forecast_element import FRBCUsageForecastElement @catch_and_convert_exceptions -class FRBCUsageForecast(GenFRBCUsageForecast, S2Message["FRBCUsageForecast"]): +class FRBCUsageForecast(GenFRBCUsageForecast, S2MessageComponent["FRBCUsageForecast"]): model_config = GenFRBCUsageForecast.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/frbc/frbc_usage_forecast_element.py b/src/s2python/frbc/frbc_usage_forecast_element.py index 370c04e..97e9524 100644 --- a/src/s2python/frbc/frbc_usage_forecast_element.py +++ b/src/s2python/frbc/frbc_usage_forecast_element.py @@ -5,12 +5,12 @@ ) from s2python.validate_values_mixin import ( catch_and_convert_exceptions, - S2Message, + S2MessageComponent, ) @catch_and_convert_exceptions -class FRBCUsageForecastElement(GenFRBCUsageForecastElement, S2Message["FRBCUsageForecastElement"]): +class FRBCUsageForecastElement(GenFRBCUsageForecastElement, S2MessageComponent["FRBCUsageForecastElement"]): model_config = GenFRBCUsageForecastElement.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/message.py b/src/s2python/message.py new file mode 100644 index 0000000..aafc009 --- /dev/null +++ b/src/s2python/message.py @@ -0,0 +1,50 @@ +from typing import Union + +from s2python.frbc import ( + FRBCActuatorStatus, + FRBCFillLevelTargetProfile, + FRBCInstruction, + FRBCLeakageBehaviour, + FRBCStorageStatus, + FRBCSystemDescription, + FRBCTimerStatus, + FRBCUsageForecast +) +from s2python.ppbc import ( + PPBCScheduleInstruction, +) + +from s2python.common import ( + Handshake, + HandshakeResponse, + InstructionStatusUpdate, + PowerForecast, + PowerMeasurement, + ReceptionStatus, + ResourceManagerDetails, + RevokeObject, + SelectControlType, + SessionRequest +) + +S2Message = Union[ + FRBCActuatorStatus, + FRBCFillLevelTargetProfile, + FRBCInstruction, + FRBCLeakageBehaviour, + FRBCStorageStatus, + FRBCSystemDescription, + FRBCTimerStatus, + FRBCUsageForecast, + PPBCScheduleInstruction, + Handshake, + HandshakeResponse, + InstructionStatusUpdate, + PowerForecast, + PowerMeasurement, + ReceptionStatus, + ResourceManagerDetails, + RevokeObject, + SelectControlType, + SessionRequest, +] diff --git a/src/s2python/ppbc/ppbc_end_interruption_instruction.py b/src/s2python/ppbc/ppbc_end_interruption_instruction.py index d53c527..2b098f1 100644 --- a/src/s2python/ppbc/ppbc_end_interruption_instruction.py +++ b/src/s2python/ppbc/ppbc_end_interruption_instruction.py @@ -5,14 +5,14 @@ ) from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) @catch_and_convert_exceptions class PPBCEndInterruptionInstruction( - GenPPBCEndInterruptionInstruction, S2Message["PPBCEndInterruptionInstruction"] + GenPPBCEndInterruptionInstruction, S2MessageComponent["PPBCEndInterruptionInstruction"] ): model_config = GenPPBCEndInterruptionInstruction.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/ppbc/ppbc_power_profile_definition.py b/src/s2python/ppbc/ppbc_power_profile_definition.py index cc4ba6a..d3926c7 100644 --- a/src/s2python/ppbc/ppbc_power_profile_definition.py +++ b/src/s2python/ppbc/ppbc_power_profile_definition.py @@ -6,7 +6,7 @@ ) from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) @@ -15,7 +15,7 @@ @catch_and_convert_exceptions class PPBCPowerProfileDefinition( - GenPPBCPowerProfileDefinition, S2Message["PPBCPowerProfileDefinition"] + GenPPBCPowerProfileDefinition, S2MessageComponent["PPBCPowerProfileDefinition"] ): model_config = GenPPBCPowerProfileDefinition.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/ppbc/ppbc_power_profile_status.py b/src/s2python/ppbc/ppbc_power_profile_status.py index d44f7e2..bec09cd 100644 --- a/src/s2python/ppbc/ppbc_power_profile_status.py +++ b/src/s2python/ppbc/ppbc_power_profile_status.py @@ -5,7 +5,7 @@ ) from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) @@ -16,7 +16,7 @@ @catch_and_convert_exceptions class PPBCPowerProfileStatus( - GenPPBCPowerProfileStatus, S2Message["PPBCPowerProfileStatus"] + GenPPBCPowerProfileStatus, S2MessageComponent["PPBCPowerProfileStatus"] ): model_config = GenPPBCPowerProfileStatus.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/ppbc/ppbc_power_sequence.py b/src/s2python/ppbc/ppbc_power_sequence.py index 95e2758..6f7af3d 100644 --- a/src/s2python/ppbc/ppbc_power_sequence.py +++ b/src/s2python/ppbc/ppbc_power_sequence.py @@ -6,7 +6,7 @@ ) from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) @@ -15,7 +15,7 @@ @catch_and_convert_exceptions -class PPBCPowerSequence(GenPPBCPowerSequence, S2Message["PPBCPowerSequence"]): +class PPBCPowerSequence(GenPPBCPowerSequence, S2MessageComponent["PPBCPowerSequence"]): model_config = GenPPBCPowerSequence.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/ppbc/ppbc_power_sequence_container.py b/src/s2python/ppbc/ppbc_power_sequence_container.py index 3a11163..08f30ff 100644 --- a/src/s2python/ppbc/ppbc_power_sequence_container.py +++ b/src/s2python/ppbc/ppbc_power_sequence_container.py @@ -7,7 +7,7 @@ ) from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) @@ -16,7 +16,7 @@ @catch_and_convert_exceptions class PPBCPowerSequenceContainer( - GenPPBCPowerSequenceContainer, S2Message["PPBCPowerSequenceContainer"] + GenPPBCPowerSequenceContainer, S2MessageComponent["PPBCPowerSequenceContainer"] ): model_config = GenPPBCPowerSequenceContainer.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/ppbc/ppbc_power_sequence_container_status.py b/src/s2python/ppbc/ppbc_power_sequence_container_status.py index 624e4d6..19e897d 100644 --- a/src/s2python/ppbc/ppbc_power_sequence_container_status.py +++ b/src/s2python/ppbc/ppbc_power_sequence_container_status.py @@ -6,14 +6,14 @@ ) from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) @catch_and_convert_exceptions class PPBCPowerSequenceContainerStatus( - GenPPBCPowerSequenceContainerStatus, S2Message["PPBCPowerSequenceContainerStatus"] + GenPPBCPowerSequenceContainerStatus, S2MessageComponent["PPBCPowerSequenceContainerStatus"] ): model_config = GenPPBCPowerSequenceContainerStatus.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/ppbc/ppbc_power_sequence_element.py b/src/s2python/ppbc/ppbc_power_sequence_element.py index 1372063..206f5ec 100644 --- a/src/s2python/ppbc/ppbc_power_sequence_element.py +++ b/src/s2python/ppbc/ppbc_power_sequence_element.py @@ -5,7 +5,7 @@ ) from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) @@ -14,7 +14,7 @@ @catch_and_convert_exceptions class PPBCPowerSequenceElement( - GenPPBCPowerSequenceElement, S2Message["PPBCPowerSequenceElement"] + GenPPBCPowerSequenceElement, S2MessageComponent["PPBCPowerSequenceElement"] ): model_config = GenPPBCPowerSequenceElement.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/ppbc/ppbc_schedule_instruction.py b/src/s2python/ppbc/ppbc_schedule_instruction.py index c794b78..2e7802d 100644 --- a/src/s2python/ppbc/ppbc_schedule_instruction.py +++ b/src/s2python/ppbc/ppbc_schedule_instruction.py @@ -5,13 +5,13 @@ ) from s2python.validate_values_mixin import ( catch_and_convert_exceptions, - S2Message, + S2MessageComponent, ) @catch_and_convert_exceptions class PPBCScheduleInstruction( - GenPPBCScheduleInstruction, S2Message["PPBCScheduleInstruction"] + GenPPBCScheduleInstruction, S2MessageComponent["PPBCScheduleInstruction"] ): model_config = GenPPBCScheduleInstruction.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/ppbc/ppbc_start_interruption_instruction.py b/src/s2python/ppbc/ppbc_start_interruption_instruction.py index f6d25ff..0924021 100644 --- a/src/s2python/ppbc/ppbc_start_interruption_instruction.py +++ b/src/s2python/ppbc/ppbc_start_interruption_instruction.py @@ -5,14 +5,14 @@ ) from s2python.validate_values_mixin import ( - S2Message, + S2MessageComponent, catch_and_convert_exceptions, ) @catch_and_convert_exceptions class PPBCStartInterruptionInstruction( - GenPPBCStartInterruptionInstruction, S2Message["PPBCStartInterruptionInstruction"] + GenPPBCStartInterruptionInstruction, S2MessageComponent["PPBCStartInterruptionInstruction"] ): model_config = GenPPBCStartInterruptionInstruction.model_config model_config["validate_assignment"] = True diff --git a/src/s2python/s2_connection.py b/src/s2python/s2_connection.py index 188ecc7..5864203 100644 --- a/src/s2python/s2_connection.py +++ b/src/s2python/s2_connection.py @@ -27,7 +27,7 @@ from s2python.s2_control_type import S2ControlType from s2python.s2_parser import S2Parser from s2python.s2_validation_error import S2ValidationError -from s2python.validate_values_mixin import S2Message +from s2python.message import S2Message from s2python.version import S2_VERSION logger = logging.getLogger("s2python") @@ -141,7 +141,7 @@ async def handle_message(self, connection: "S2Connection", msg: S2Message) -> No """ handler = self.handlers.get(type(msg)) if handler is not None: - send_okay = SendOkay(connection, msg.message_id) # type: ignore[attr-defined] + send_okay = SendOkay(connection, msg.message_id) # type: ignore[attr-defined, union-attr] try: if asyncio.iscoroutinefunction(handler): @@ -158,9 +158,9 @@ def do_message() -> None: except Exception: if not send_okay.status_is_send.is_set(): await connection.respond_with_reception_status( - subject_message_id=str(msg.message_id), # type: ignore[attr-defined] + subject_message_id=str(msg.message_id), # type: ignore[attr-defined, union-attr] status=ReceptionStatusValues.PERMANENT_ERROR, - diagnostic_label=f"While processing message {msg.message_id} " # type: ignore[attr-defined] + diagnostic_label=f"While processing message {msg.message_id} " # type: ignore[attr-defined, union-attr] # pylint: disable=line-too-long f"an unrecoverable error occurred.", ) raise @@ -490,17 +490,17 @@ async def send_msg_and_await_reception_status_async( await self._send_and_forget(s2_msg) logger.debug( "Waiting for ReceptionStatus for %s %s seconds", - s2_msg.message_id, # type: ignore[attr-defined] + s2_msg.message_id, # type: ignore[attr-defined, union-attr] timeout_reception_status, ) try: reception_status = await self.reception_status_awaiter.wait_for_reception_status( - s2_msg.message_id, timeout_reception_status # type: ignore[attr-defined] + s2_msg.message_id, timeout_reception_status # type: ignore[attr-defined, union-attr] ) except TimeoutError: logger.error( "Did not receive a reception status on time for %s", - s2_msg.message_id, # type: ignore[attr-defined] + s2_msg.message_id, # type: ignore[attr-defined, union-attr] ) self._stop_event.set() raise diff --git a/src/s2python/s2_control_type.py b/src/s2python/s2_control_type.py index 43f3b8e..982c9be 100644 --- a/src/s2python/s2_control_type.py +++ b/src/s2python/s2_control_type.py @@ -4,7 +4,7 @@ from s2python.common import ControlType as ProtocolControlType from s2python.frbc import FRBCInstruction from s2python.ppbc import PPBCScheduleInstruction -from s2python.validate_values_mixin import S2Message +from s2python.message import S2Message if typing.TYPE_CHECKING: from s2python.s2_connection import S2Connection, MessageHandlers diff --git a/src/s2python/s2_parser.py b/src/s2python/s2_parser.py index e1a5c43..403503f 100644 --- a/src/s2python/s2_parser.py +++ b/src/s2python/s2_parser.py @@ -26,14 +26,15 @@ ) from s2python.ppbc import PPBCScheduleInstruction -from s2python.validate_values_mixin import S2Message +from s2python.message import S2Message +from s2python.validate_values_mixin import S2MessageComponent from s2python.s2_validation_error import S2ValidationError LOGGER = logging.getLogger(__name__) S2MessageType = str -M = TypeVar("M", bound=S2Message) +M = TypeVar("M", bound=S2MessageComponent) # May be generated with development_utilities/generate_s2_message_type_to_class.py diff --git a/src/s2python/validate_values_mixin.py b/src/s2python/validate_values_mixin.py index 7d0d9d6..cc9c6fd 100644 --- a/src/s2python/validate_values_mixin.py +++ b/src/s2python/validate_values_mixin.py @@ -15,7 +15,7 @@ C = TypeVar("C", bound="BaseModel") -class S2Message(BaseModel, Generic[C]): +class S2MessageComponent(BaseModel, Generic[C]): def to_json(self: C) -> str: try: return self.model_dump_json(by_alias=True, exclude_none=True) @@ -59,7 +59,7 @@ def inner(*args: List[Any], **kwargs: Dict[str, Any]) -> Any: return inner -def catch_and_convert_exceptions(input_class: Type[S2Message[B_co]]) -> Type[S2Message[B_co]]: +def catch_and_convert_exceptions(input_class: Type[S2MessageComponent[B_co]]) -> Type[S2MessageComponent[B_co]]: input_class.__init__ = convert_to_s2exception(input_class.__init__) # type: ignore[method-assign] input_class.__setattr__ = convert_to_s2exception(input_class.__setattr__) # type: ignore[method-assign] input_class.model_validate_json = convert_to_s2exception( # type: ignore[method-assign]