You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug flowmachine.features.location.flows.InOutFlow has a direction parameter to specify whether the query is an inflow or an outflow. We use the following enum to ensure the direction is either "to" or "from":
class Direction(str, Enum):
OUTFLOW = "from"
INFLOW = "to"
The str mixin ensured that Direction objects could be used as strings, e.g. f"pcod_{self.direction}" formats to either "pcod_from" or "pcod_to".
But python 3.11 changes this behaviour (see https://blog.pecar.me/python-enum for a description of the change), so that f"pcod_{self.direction}" formats to "pcod_Direction.INFLOW" or "pcod_Direction.OUTFLOW", which breaks the in/outflow SQL query.
Python 3.11 introduces a StrEnum class that can be used instead. So either we can make the definition of Direction conditional on the python version, or we can explicitly use direction.value instead of direction for string formatting.
I suspect there are other places we use the class MyEnum(str, Enum) hack, which may also be broken.
The text was updated successfully, but these errors were encountered:
Describe the bug
flowmachine.features.location.flows.InOutFlow
has adirection
parameter to specify whether the query is an inflow or an outflow. We use the following enum to ensure the direction is either"to"
or"from"
:The
str
mixin ensured thatDirection
objects could be used as strings, e.g.f"pcod_{self.direction}"
formats to either"pcod_from"
or"pcod_to"
.But python 3.11 changes this behaviour (see https://blog.pecar.me/python-enum for a description of the change), so that
f"pcod_{self.direction}"
formats to"pcod_Direction.INFLOW"
or"pcod_Direction.OUTFLOW"
, which breaks the in/outflow SQL query.Python 3.11 introduces a
StrEnum
class that can be used instead. So either we can make the definition ofDirection
conditional on the python version, or we can explicitly usedirection.value
instead ofdirection
for string formatting.I suspect there are other places we use the
class MyEnum(str, Enum)
hack, which may also be broken.The text was updated successfully, but these errors were encountered: