Skip to content

Commit

Permalink
changes based on PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmirsky committed Dec 13, 2024
1 parent f616705 commit ff1e071
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 43 deletions.
2 changes: 1 addition & 1 deletion ocpp/v201/call_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class SendLocalList:

@dataclass
class SetChargingProfile:
status: enums.ChargingProfileStatus
status: enums.ChargingProfileStatusEnumType
status_info: Optional[datatypes.StatusInfoType] = None
custom_data: Optional[Dict[str, Any]] = None

Expand Down
4 changes: 2 additions & 2 deletions ocpp/v201/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ class UnitOfMeasureType:
UnitOfMeasureType is used by: SampledValueType
"""

unit: Optional[Union[enums.StandardizedUnitsOfMeasureEnumType, str]] = None
unit: Optional[Union[enums.StandardizedUnitsOfMeasureType, str]] = None
multiplier: Optional[int] = None


Expand Down Expand Up @@ -642,7 +642,7 @@ class VPNType:
user: str
password: str
key: str
type: enums.VPNType
type: enums.VPNEnumType
group: Optional[str] = None


Expand Down
44 changes: 8 additions & 36 deletions ocpp/v201/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,6 @@ class StrEnum(str, Enum): # pragma: no cover
pass # pragma: no cover


class DeprecatedEnumWrapper:
"""
Since enums can't be subclassed in order to add a deprecation warning,
this class is included to help warn users of deprecated enums.
"""

def __init__(self, enum_class, alias_name):
self.enum_class = enum_class
self.alias_name = alias_name

def __getattr__(self, name):
warn(
(
f"Enum '{self.alias_name}' is deprecated, "
+ "instead use '{self.enum_class.__name__}'"
)
)
return getattr(self.enum_class, name)


class Action(StrEnum):
"""An Action is a required part of a Call message."""

Expand Down Expand Up @@ -365,7 +345,7 @@ class ChargingProfilePurposeEnumType(StrEnum):
tx_profile = "TxProfile"


class ChargingProfileStatus(StrEnum):
class ChargingProfileStatusEnumType(StrEnum):
"""
Status returned in response to SetChargingProfile.req.
"""
Expand Down Expand Up @@ -756,9 +736,6 @@ class IdTokenEnumType(StrEnum):
no_authorization = "NoAuthorization"


IdTokenType = DeprecatedEnumWrapper(IdTokenEnumType, "IdTokenType")


class InstallCertificateStatusEnumType(StrEnum):
"""
InstallCertificateStatusEnumType is used by
Expand Down Expand Up @@ -1330,7 +1307,7 @@ class UploadLogStatusEnumType(StrEnum):
accepted_canceled = "AcceptedCanceled"


class VPNType(StrEnum):
class VPNEnumType(StrEnum):
"""
Enumeration of VPN Types used in SetNetworkProfileRequest.VPNType
"""
Expand All @@ -1344,7 +1321,7 @@ class VPNType(StrEnum):
# DataTypes


class StandardizedUnitsOfMeasureEnumType(StrEnum):
class StandardizedUnitsOfMeasureType(StrEnum):
"""
Allowable values of the optional "unit" field of a Value element, as used
in MeterValues.req and StopTransaction.req messages. Default value of
Expand Down Expand Up @@ -1387,12 +1364,7 @@ class StandardizedUnitsOfMeasureEnumType(StrEnum):
k = "K"


UnitOfMeasureType = DeprecatedEnumWrapper(
StandardizedUnitsOfMeasureEnumType, "UnitOfMeasureType"
)


class StatusInfoReasonEnumType(StrEnum):
class StatusInfoReasonType(StrEnum):
"""
Standardized reason codes for StatusInfo defined in Appendix 5. v1.3
"""
Expand Down Expand Up @@ -1442,7 +1414,7 @@ class StatusInfoReasonEnumType(StrEnum):
write_only = "WriteOnly"


class SecurityEventEnumType(StrEnum):
class SecurityEventType(StrEnum):
"""
Security Events as listed in Appendices (Appendix 1. Security Events) v1.3
"""
Expand Down Expand Up @@ -1620,7 +1592,7 @@ class StandardizedVariableName(StrEnum):
impedance = "Impedance"
imsi = "IMSI"
interval = "Interval"
iso_15118_evse_id = "ISO15118EvseId"
iso15118_evse_id = "ISO15118EvseId"
length = "Length"
light = "Light"
manufacturer = "Manufacturer"
Expand Down Expand Up @@ -2212,8 +2184,8 @@ class ConnectedEVVariableName(StrEnum):
charging_complete_full = "ChargingCompleteFull"

# Status values
battery_over_voltage = " BatteryOvervoltage"
battery_under_voltage = " BatteryUndervoltage"
battery_overvoltage = " BatteryOvervoltage"
battery_undervoltage = " BatteryUndervoltage"
charging_current_deviation = " ChargingCurrentDeviation"
battery_temperature = "BatteryTemperature"
voltage_deviation = "VoltageDeviation"
Expand Down
8 changes: 4 additions & 4 deletions tests/v201/test_v201_data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
ReasonEnumType,
SetMonitoringStatusEnumType,
SetVariableStatusEnumType,
StandardizedUnitsOfMeasureEnumType,
VPNType,
StandardizedUnitsOfMeasureType,
VPNEnumType,
)

T = TypeVar("T", bound="dataclass")
Expand Down Expand Up @@ -708,7 +708,7 @@ def test_network_connection_profile_type():
message_timeout=30,
security_profile=1,
ocpp_interface=OCPPInterfaceEnumType.wired0,
vpn=VPNType.ikev2,
vpn=VPNEnumType.ikev2,
)

new_ncpt = to_datatype(NetworkConnectionProfileType, ncpt)
Expand Down Expand Up @@ -844,7 +844,7 @@ def test_sampled_value_type():
phase=PhaseEnumType.l1,
location=LocationEnumType.outlet,
unit_of_measure=UnitOfMeasureType(
unit=StandardizedUnitsOfMeasureEnumType.v, multiplier=0
unit=StandardizedUnitsOfMeasureType.v, multiplier=0
),
)

Expand Down

0 comments on commit ff1e071

Please sign in to comment.