Skip to content

Commit

Permalink
fix: pydantic errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwcrft committed Oct 6, 2023
1 parent 1ff65d4 commit 669b674
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions iso15118/shared/messages/datatypes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum
from typing import List, Literal

from pydantic import Field, model_validator
from pydantic import Field, root_validator

from iso15118.shared.messages import BaseModel
from iso15118.shared.messages.enums import (
Expand Down Expand Up @@ -34,7 +34,7 @@ class PhysicalValue(BaseModel):
# XSD type byte with value range [-3..3]
multiplier: int = Field(..., ge=-3, le=3, alias="Multiplier")

@model_validator(mode="after")
@root_validator
def validate_value_range(cls, values):
"""
Validator for the range of the PhysicalValue type
Expand Down
6 changes: 3 additions & 3 deletions iso15118/shared/messages/din_spec/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from abc import ABC
from typing import Optional, Tuple, Type

from pydantic import Field, validator, model_validator
from pydantic import Field, root_validator, validator

from iso15118.shared.exceptions import V2GMessageValidationError
from iso15118.shared.messages import BaseModel
Expand Down Expand Up @@ -213,7 +213,7 @@ class ChargeParameterDiscoveryReq(BodyBase):
None, alias="DC_EVChargeParameter"
)

@model_validator(mode="before")
@root_validator
def only_dc_charge_params(cls, values):
"""
Only dc_ev_charge_parameter must be set,
Expand All @@ -233,7 +233,7 @@ def only_dc_charge_params(cls, values):
):
return values

@model_validator(mode="after")
@root_validator
def validate_requested_energy_mode(cls, values):
"""
requested_energy_mode must be either DC_extended or DC_core
Expand Down
8 changes: 4 additions & 4 deletions iso15118/shared/messages/iso15118_2/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from abc import ABC
from typing import Optional, Tuple, Type

from pydantic import Field, validator, model_validator
from pydantic import Field, root_validator, validator

from iso15118.shared.exceptions import V2GMessageValidationError
from iso15118.shared.messages import BaseModel
Expand Down Expand Up @@ -101,7 +101,7 @@ class AuthorizationReq(BodyBase):
None, min_length=16, max_length=16, alias="GenChallenge"
)

@model_validator(mode="before")
@root_validator
def both_fields_set_or_unset(cls, values):
"""
If the AuthorizationReq is digitally signed, then both the
Expand Down Expand Up @@ -220,7 +220,7 @@ class ChargeParameterDiscoveryReq(BodyBase):
None, alias="DC_EVChargeParameter"
)

@model_validator(mode="before")
@root_validator
def either_ac_or_dc_charge_params(cls, values):
"""
Either ac_ev_charge_parameter or dc_ev_charge_parameter must be set,
Expand All @@ -243,7 +243,7 @@ def either_ac_or_dc_charge_params(cls, values):
):
return values

@model_validator(mode="after")
@root_validator
def requested_energy_mode_must_match_charge_parameter(cls, values):
"""
Check that the requested_energy_mode matches the charge parameter. If
Expand Down
4 changes: 2 additions & 2 deletions tests/iso15118_2/secc/states/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ def get_v2g_message_power_delivery_req_charging_profile_in_boundary_valid():
profile_entries=[
ProfileEntryDetails(
start=0,
max_power=PVPMax(Multiplier=0, Value=11000, Unit=UnitSymbol.WATT),
max_power=PVPMax(multiplier=0, value=11000, unit=UnitSymbol.WATT),
max_phases_in_use=3,
),
ProfileEntryDetails(
start=1800,
max_power=PVPMax(Multiplier=0, Value=7000, Unit=UnitSymbol.WATT),
max_power=PVPMax(multiplier=0, value=7000, unit=UnitSymbol.WATT),
max_phases_in_use=3,
),
]
Expand Down

0 comments on commit 669b674

Please sign in to comment.