Skip to content
Open
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
2 changes: 1 addition & 1 deletion ci/generate_s2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


. .venv/bin/activate
datamodel-codegen --input specification/openapi.yml --input-file-type openapi --output-model-type pydantic_v2.BaseModel --output src/s2python/generated/gen_s2.py --use-one-literal-as-default --use-subclass-enum --output-datetime-class AwareDatetime --use-double-quotes
datamodel-codegen --input specification/openapi.yml --input-file-type openapi --output-model-type pydantic_v2.BaseModel --output src/s2python/generated/gen_s2.py --use-one-literal-as-default --use-subclass-enum --output-datetime-class AwareDatetime --use-double-quotes --base-class s2python.s2_base_model.S2BaseModel
7 changes: 4 additions & 3 deletions src/s2python/common/handshake.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

from s2python.generated.gen_s2 import Handshake as GenHandshake
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

message_id: uuid.UUID = GenHandshake.model_fields["message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
message_id: uuid.UUID = copy_field(GenHandshake.model_fields["message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
7 changes: 4 additions & 3 deletions src/s2python/common/handshake_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

from s2python.generated.gen_s2 import HandshakeResponse as GenHandshakeResponse
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

message_id: uuid.UUID = GenHandshakeResponse.model_fields["message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
message_id: uuid.UUID = copy_field(GenHandshakeResponse.model_fields["message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
9 changes: 5 additions & 4 deletions src/s2python/common/instruction_status_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
InstructionStatusUpdate as GenInstructionStatusUpdate,
)
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

message_id: uuid.UUID = GenInstructionStatusUpdate.model_fields["message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
instruction_id: uuid.UUID = GenInstructionStatusUpdate.model_fields["instruction_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
message_id: uuid.UUID = copy_field(GenInstructionStatusUpdate.model_fields["message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
instruction_id: uuid.UUID = copy_field(GenInstructionStatusUpdate.model_fields["instruction_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
4 changes: 2 additions & 2 deletions src/s2python/common/number_range.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any

from s2python.validate_values_mixin import (
copy_config,
S2MessageComponent,
catch_and_convert_exceptions,
)
Expand All @@ -9,8 +10,7 @@

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

def __hash__(self) -> int:
return hash(f"{self.start_of_range}|{self.end_of_range}")
Expand Down
9 changes: 5 additions & 4 deletions src/s2python/common/power_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
from s2python.common.power_forecast_element import PowerForecastElement
from s2python.generated.gen_s2 import PowerForecast as GenPowerForecast
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

message_id: uuid.UUID = GenPowerForecast.model_fields["message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
elements: List[PowerForecastElement] = GenPowerForecast.model_fields["elements"] # type: ignore[assignment,reportIncompatibleVariableOverride]
message_id: uuid.UUID = copy_field(GenPowerForecast.model_fields["message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
elements: List[PowerForecastElement] = copy_field(GenPowerForecast.model_fields["elements"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
9 changes: 5 additions & 4 deletions src/s2python/common/power_forecast_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
PowerForecastElement as GenPowerForecastElement,
)
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)
Expand All @@ -17,12 +19,11 @@

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

duration: Duration = GenPowerForecastElement.model_fields["duration"] # type: ignore[assignment,reportIncompatibleVariableOverride]
duration: Duration = copy_field(GenPowerForecastElement.model_fields["duration"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
power_values: List[PowerForecastValue] = ( # type: ignore[reportIncompatibleVariableOverride]
GenPowerForecastElement.model_fields["power_values"] # type: ignore[assignment]
copy_field(GenPowerForecastElement.model_fields["power_values"]) # type: ignore[assignment]
)

@model_validator(mode="after")
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 (
copy_config,
catch_and_convert_exceptions,
S2MessageComponent,
)


@catch_and_convert_exceptions
class PowerForecastValue(GenPowerForecastValue, S2MessageComponent):
model_config = GenPowerForecastValue.model_config
model_config["validate_assignment"] = True
model_config = copy_config(GenPowerForecastValue.model_config, validate_assignment=True)
9 changes: 5 additions & 4 deletions src/s2python/common/power_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
CommodityQuantity,
)
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

message_id: uuid.UUID = GenPowerMeasurement.model_fields["message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
values: List[PowerValue] = GenPowerMeasurement.model_fields["values"] # type: ignore[assignment,reportIncompatibleVariableOverride]
message_id: uuid.UUID = copy_field(GenPowerMeasurement.model_fields["message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
values: List[PowerValue] = copy_field(GenPowerMeasurement.model_fields["values"]) # type: ignore[assignment,reportIncompatibleVariableOverride]

@model_validator(mode="after")
def validate_values_at_most_one_per_commodity_quantity(self) -> Self:
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,15 +4,15 @@

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


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

@model_validator(mode="after")
def validate_start_end_order(self) -> Self:
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 (
copy_config,
catch_and_convert_exceptions,
S2MessageComponent,
)


@catch_and_convert_exceptions
class PowerValue(GenPowerValue, S2MessageComponent):
model_config = GenPowerValue.model_config
model_config["validate_assignment"] = True
model_config = copy_config(GenPowerValue.model_config, validate_assignment=True)
7 changes: 4 additions & 3 deletions src/s2python/common/reception_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

from s2python.generated.gen_s2 import ReceptionStatus as GenReceptionStatus
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

subject_message_id: uuid.UUID = GenReceptionStatus.model_fields["subject_message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
subject_message_id: uuid.UUID = copy_field(GenReceptionStatus.model_fields["subject_message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
15 changes: 8 additions & 7 deletions src/s2python/common/resource_manager_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
ResourceManagerDetails as GenResourceManagerDetails,
)
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

instruction_processing_delay: Duration = GenResourceManagerDetails.model_fields[ # type: ignore[assignment,reportIncompatibleVariableOverride]
instruction_processing_delay: Duration = copy_field(GenResourceManagerDetails.model_fields[ # type: ignore[assignment,reportIncompatibleVariableOverride]
"instruction_processing_delay"
]
message_id: uuid.UUID = GenResourceManagerDetails.model_fields["message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
resource_id: uuid.UUID = GenResourceManagerDetails.model_fields["resource_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
roles: List[Role] = GenResourceManagerDetails.model_fields["roles"] # type: ignore[assignment,reportIncompatibleVariableOverride]
])
message_id: uuid.UUID = copy_field(GenResourceManagerDetails.model_fields["message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
resource_id: uuid.UUID = copy_field(GenResourceManagerDetails.model_fields["resource_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
roles: List[Role] = copy_field(GenResourceManagerDetails.model_fields["roles"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
9 changes: 5 additions & 4 deletions src/s2python/common/revoke_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

from s2python.generated.gen_s2 import RevokeObject as GenRevokeObject
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

message_id: uuid.UUID = GenRevokeObject.model_fields["message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
object_id: uuid.UUID = GenRevokeObject.model_fields["object_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
message_id: uuid.UUID = copy_field(GenRevokeObject.model_fields["message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
object_id: uuid.UUID = copy_field(GenRevokeObject.model_fields["object_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
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 (
copy_config,
S2MessageComponent,
catch_and_convert_exceptions,
)


@catch_and_convert_exceptions
class Role(GenRole, S2MessageComponent):
model_config = GenRole.model_config
model_config["validate_assignment"] = True
model_config = copy_config(GenRole.model_config, validate_assignment=True)
7 changes: 4 additions & 3 deletions src/s2python/common/select_control_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

from s2python.generated.gen_s2 import SelectControlType as GenSelectControlType
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

message_id: uuid.UUID = GenSelectControlType.model_fields["message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
message_id: uuid.UUID = copy_field(GenSelectControlType.model_fields["message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
7 changes: 4 additions & 3 deletions src/s2python/common/session_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

from s2python.generated.gen_s2 import SessionRequest as GenSessionRequest
from s2python.validate_values_mixin import (
copy_config,
copy_field,
catch_and_convert_exceptions,
S2MessageComponent,
)


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

message_id: uuid.UUID = GenSessionRequest.model_fields["message_id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
message_id: uuid.UUID = copy_field(GenSessionRequest.model_fields["message_id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
9 changes: 5 additions & 4 deletions src/s2python/common/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
from s2python.common.duration import Duration
from s2python.generated.gen_s2 import Timer as GenTimer
from s2python.validate_values_mixin import (
copy_config,
copy_field,
S2MessageComponent,
catch_and_convert_exceptions,
)


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

id: uuid.UUID = GenTimer.model_fields["id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
duration: Duration = GenTimer.model_fields["duration"] # type: ignore[assignment,reportIncompatibleVariableOverride]
id: uuid.UUID = copy_field(GenTimer.model_fields["id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
duration: Duration = copy_field(GenTimer.model_fields["duration"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
19 changes: 10 additions & 9 deletions src/s2python/common/transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
from s2python.common.duration import Duration
from s2python.generated.gen_s2 import Transition as GenTransition
from s2python.validate_values_mixin import (
copy_config,
copy_field,
S2MessageComponent,
catch_and_convert_exceptions,
)


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

id: uuid.UUID = GenTransition.model_fields["id"] # type: ignore[assignment,reportIncompatibleVariableOverride]
from_: uuid.UUID = GenTransition.model_fields["from_"] # type: ignore[assignment,reportIncompatibleVariableOverride]
to: uuid.UUID = GenTransition.model_fields["to"] # type: ignore[assignment,reportIncompatibleVariableOverride]
start_timers: List[uuid.UUID] = GenTransition.model_fields["start_timers"] # type: ignore[assignment,reportIncompatibleVariableOverride]
blocking_timers: List[uuid.UUID] = GenTransition.model_fields["blocking_timers"] # type: ignore[assignment,reportIncompatibleVariableOverride]
transition_duration: Optional[Duration] = GenTransition.model_fields[ # type: ignore[assignment,reportIncompatibleVariableOverride]
id: uuid.UUID = copy_field(GenTransition.model_fields["id"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
from_: uuid.UUID = copy_field(GenTransition.model_fields["from_"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
to: uuid.UUID = copy_field(GenTransition.model_fields["to"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
start_timers: List[uuid.UUID] = copy_field(GenTransition.model_fields["start_timers"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
blocking_timers: List[uuid.UUID] = copy_field(GenTransition.model_fields["blocking_timers"]) # type: ignore[assignment,reportIncompatibleVariableOverride]
transition_duration: Optional[Duration] = copy_field(GenTransition.model_fields[ # type: ignore[assignment,reportIncompatibleVariableOverride]
"transition_duration"
]
])
Loading