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

For Python 3.11 a fix for how enums are formatted as strings #550

Merged

Conversation

Jared-Newell-Mobility
Copy link
Contributor

See #447

Copy link
Collaborator

@OrangeTux OrangeTux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still quite a few enums which subclass from (str, Enum). See

$ grep -R "str, Enum" ocpp/ 
ocpp/v201/enums.py:    class StrEnum(str, Enum):  # pragma: no cover
ocpp/v201/enums.py:class PhysicalComponentName(str, Enum):
ocpp/v201/enums.py:class GenericVariableName(str, Enum):
ocpp/v201/enums.py:class AlignedDataCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class AuthCacheCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class AuthCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class CHAdeMOCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class ClockCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class CustomizationCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class DeviceDataCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class DeviceDataCtrlrInstanceName(str, Enum):
ocpp/v201/enums.py:class DisplayMessageCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class ISO15118CtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class LocalAuthListCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class MonitoringCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class MonitoringCtrlrInstanceName(str, Enum):
ocpp/v201/enums.py:class OCPPCommCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class OCPPCommCtrlrInstanceName(str, Enum):
ocpp/v201/enums.py:class ReservationCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class SampledDataCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class SecurityCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class SmartChargingCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class SmartChargingCtrlrInstanceName(str, Enum):
ocpp/v201/enums.py:class TariffCostCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class TariffCostCtrlrInstanceName(str, Enum):
ocpp/v201/enums.py:class TxCtrlrVariableName(str, Enum):
ocpp/v201/enums.py:class AccessBarrierVariableName(str, Enum):
ocpp/v201/enums.py:class AcDcConverterVariableName(str, Enum):
ocpp/v201/enums.py:class AcPhaseSelectorVariableName(str, Enum):
ocpp/v201/enums.py:class ActuatorVariableName(str, Enum):
ocpp/v201/enums.py:class AirCoolingSystemVariableName(str, Enum):
ocpp/v201/enums.py:class AreaVentilationVariableName(str, Enum):
ocpp/v201/enums.py:class BayOccupancySensorVariableName(str, Enum):
ocpp/v201/enums.py:class BeaconLightingVariableName(str, Enum):
ocpp/v201/enums.py:class CableBreakawaySensorVariableName(str, Enum):
ocpp/v201/enums.py:class CaseAccessSensorVariableName(str, Enum):
ocpp/v201/enums.py:class ChargingStationVariableName(str, Enum):
ocpp/v201/enums.py:class ChargingStatusIndicatorVariableName(str, Enum):
ocpp/v201/enums.py:class ConnectedEVVariableName(str, Enum):
ocpp/v201/enums.py:class ChargingStateVariableName(str, Enum):
ocpp/v201/enums.py:class ConnectorVariableName(str, Enum):
ocpp/v201/enums.py:class ConnectorHolsterReleaseVariableName(str, Enum):
ocpp/v201/enums.py:class ConnectorHolsterSensorVariableName(str, Enum):
ocpp/v201/enums.py:class ConnectorPlugRetentionLockVariableName(str, Enum):
ocpp/v201/enums.py:class ConnectorProtectionReleaseVariableName(str, Enum):
ocpp/v201/enums.py:class ControllerVariableName(str, Enum):
ocpp/v201/enums.py:class ControlMeteringVariableName(str, Enum):
ocpp/v201/enums.py:class CPPWMControllerVariableName(str, Enum):
ocpp/v201/enums.py:class DataLinkVariableName(str, Enum):
ocpp/v201/enums.py:class DisplayVariableName(str, Enum):
ocpp/v201/enums.py:class DistributionPanelVariableName(str, Enum):
ocpp/v201/enums.py:class ElectricalFeedVariableName(str, Enum):
ocpp/v201/enums.py:class ELVSupplyVariableName(str, Enum):
ocpp/v201/enums.py:class EmergencyStopSensorVariableName(str, Enum):
ocpp/v201/enums.py:class EnvironmentalLightingVariableName(str, Enum):
ocpp/v201/enums.py:class EVRetentionLockVariableName(str, Enum):
ocpp/v201/enums.py:class EVSEVariableName(str, Enum):
ocpp/v201/enums.py:class ExternalTemperatureSensorVariableName(str, Enum):
ocpp/v201/enums.py:class FiscalMeteringVariableName(str, Enum):
ocpp/v201/enums.py:class FloodSensorVariableName(str, Enum):
ocpp/v201/enums.py:class GroundIsolationProtectionVariableName(str, Enum):
ocpp/v201/enums.py:class HeaterVariableName(str, Enum):
ocpp/v201/enums.py:class HumiditySensorVariableName(str, Enum):
ocpp/v201/enums.py:class LightSensorVariableName(str, Enum):
ocpp/v201/enums.py:class LiquidCoolingSystemVariableName(str, Enum):
ocpp/v201/enums.py:class LocalAvailabilitySensorVariableName(str, Enum):
ocpp/v201/enums.py:class LocalControllerVariableName(str, Enum):
ocpp/v201/enums.py:class LocalEnergyStorageVariableName(str, Enum):
ocpp/v201/enums.py:class OverCurrentProtectionVariableName(str, Enum):
ocpp/v201/enums.py:class OverCurrentProtectionRecloserVariableName(str, Enum):
ocpp/v201/enums.py:class PowerContactorVariableName(str, Enum):
ocpp/v201/enums.py:class RCDVariableName(str, Enum):
ocpp/v201/enums.py:class RCDRecloserVariableName(str, Enum):
ocpp/v201/enums.py:class RealTimeClockVariableName(str, Enum):
ocpp/v201/enums.py:class ShockSensorVariableName(str, Enum):
ocpp/v201/enums.py:class SpacesCountSignageVariableName(str, Enum):
ocpp/v201/enums.py:class SwitchVariableName(str, Enum):
ocpp/v201/enums.py:class TemperatureSensorVariableName(str, Enum):
ocpp/v201/enums.py:class TiltSensorVariableName(str, Enum):
ocpp/v201/enums.py:class TokenReaderVariableName(str, Enum):
ocpp/v201/enums.py:class UIInputVariableName(str, Enum):
ocpp/v201/enums.py:class UpstreamProtectionTriggerVariableName(str, Enum):
ocpp/v201/enums.py:class VehicleIdSensorVariableName(str, Enum):
ocpp/v16/enums.py:    class StrEnum(str, Enum):  # pragma: no cover

When running the tests in Python 3.11, the tests fail with:

tests/v201/test_v201_enums.py:1: in <module>
    from ocpp.v201.enums import ConnectorType, DataType, TxStartStopPointType
ocpp/v201/enums.py:1398: in <module>
    class PhysicalComponentName(str, Enum):
E   NameError: name 'Enum' is not defined

…-formatted-as-string

# Conflicts:
#	CHANGELOG.md
…-enums-are-formatted-as-string' into Python-3.11-changes-behavior-how-enums-are-formatted-as-string

# Conflicts:
#	CHANGELOG.md
@Jared-Newell-Mobility
Copy link
Contributor Author

New Enums updated, and now ...

tests/v201/test_v201_enums.py ... [100%]

================================================================================================================================================== 3 passed in 0.03s ===================================================================================================================================================

Copy link
Collaborator

@OrangeTux OrangeTux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@OrangeTux OrangeTux merged commit fab6536 into master Jan 15, 2024
5 checks passed
@OrangeTux OrangeTux deleted the Python-3.11-changes-behavior-how-enums-are-formatted-as-string branch January 15, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants