Skip to content

[python-experimental] Fixes enum is comparison #12176

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

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def NONE(cls):
@classmethod
@property
def {{name}}(cls):
return cls._enum_by_value[{{{value}}}]({{{value}}})
return cls({{{value}}})
{{/each}}
{{/with}}
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,7 @@ class Schema:
# Use case: value is None, True, False, or an enum value
value = arg
for key in path[1:]:
# if path is bigger than one, get the value that mfg_cls validated
value = value[key]
if hasattr(mfg_cls, '_enum_by_value'):
mfg_cls = mfg_cls._enum_by_value[value]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class _items(
@classmethod
@property
def GREATER_THAN(cls):
return cls._enum_by_value[">"](">")
return cls(">")

@classmethod
@property
def DOLLAR(cls):
return cls._enum_by_value["$"]("$")
return cls("$")


class EnumQueryStringSchema(
Expand All @@ -106,17 +106,17 @@ class EnumQueryStringSchema(
@classmethod
@property
def _ABC(cls):
return cls._enum_by_value["_abc"]("_abc")
return cls("_abc")

@classmethod
@property
def EFG(cls):
return cls._enum_by_value["-efg"]("-efg")
return cls("-efg")

@classmethod
@property
def XYZ(cls):
return cls._enum_by_value["(xyz)"]("(xyz)")
return cls("(xyz)")


class EnumQueryIntegerSchema(
Expand All @@ -132,12 +132,12 @@ class EnumQueryIntegerSchema(
@classmethod
@property
def POSITIVE_1(cls):
return cls._enum_by_value[1](1)
return cls(1)

@classmethod
@property
def NEGATIVE_2(cls):
return cls._enum_by_value[-2](-2)
return cls(-2)


class EnumQueryDoubleSchema(
Expand All @@ -153,12 +153,12 @@ class EnumQueryDoubleSchema(
@classmethod
@property
def POSITIVE_1_PT_1(cls):
return cls._enum_by_value[1.1](1.1)
return cls(1.1)

@classmethod
@property
def NEGATIVE_1_PT_2(cls):
return cls._enum_by_value[-1.2](-1.2)
return cls(-1.2)
RequestRequiredQueryParams = typing.TypedDict(
'RequestRequiredQueryParams',
{
Expand Down Expand Up @@ -225,12 +225,12 @@ class _items(
@classmethod
@property
def GREATER_THAN(cls):
return cls._enum_by_value[">"](">")
return cls(">")

@classmethod
@property
def DOLLAR(cls):
return cls._enum_by_value["$"]("$")
return cls("$")


class EnumHeaderStringSchema(
Expand All @@ -247,17 +247,17 @@ class EnumHeaderStringSchema(
@classmethod
@property
def _ABC(cls):
return cls._enum_by_value["_abc"]("_abc")
return cls("_abc")

@classmethod
@property
def EFG(cls):
return cls._enum_by_value["-efg"]("-efg")
return cls("-efg")

@classmethod
@property
def XYZ(cls):
return cls._enum_by_value["(xyz)"]("(xyz)")
return cls("(xyz)")
RequestRequiredHeaderParams = typing.TypedDict(
'RequestRequiredHeaderParams',
{
Expand Down Expand Up @@ -313,12 +313,12 @@ class _items(
@classmethod
@property
def GREATER_THAN(cls):
return cls._enum_by_value[">"](">")
return cls(">")

@classmethod
@property
def DOLLAR(cls):
return cls._enum_by_value["$"]("$")
return cls("$")


class enum_form_string(
Expand All @@ -335,17 +335,17 @@ class enum_form_string(
@classmethod
@property
def _ABC(cls):
return cls._enum_by_value["_abc"]("_abc")
return cls("_abc")

@classmethod
@property
def EFG(cls):
return cls._enum_by_value["-efg"]("-efg")
return cls("-efg")

@classmethod
@property
def XYZ(cls):
return cls._enum_by_value["(xyz)"]("(xyz)")
return cls("(xyz)")


def __new__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ class _items(
@classmethod
@property
def AVAILABLE(cls):
return cls._enum_by_value["available"]("available")
return cls("available")

@classmethod
@property
def PENDING(cls):
return cls._enum_by_value["pending"]("pending")
return cls("pending")

@classmethod
@property
def SOLD(cls):
return cls._enum_by_value["sold"]("sold")
return cls("sold")
RequestRequiredQueryParams = typing.TypedDict(
'RequestRequiredQueryParams',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class className(
@classmethod
@property
def BASQUEPIG(cls):
return cls._enum_by_value["BasquePig"]("BasquePig")
return cls("BasquePig")


def __new__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ class BooleanEnum(
@classmethod
@property
def TRUE(cls):
return cls._enum_by_value[True](True)
return cls(True)
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class quadrilateralType(
@classmethod
@property
def COMPLEXQUADRILATERAL(cls):
return cls._enum_by_value["ComplexQuadrilateral"]("ComplexQuadrilateral")
return cls("ComplexQuadrilateral")


def __new__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class Currency(
@classmethod
@property
def EUR(cls):
return cls._enum_by_value["eur"]("eur")
return cls("eur")

@classmethod
@property
def USD(cls):
return cls._enum_by_value["usd"]("usd")
return cls("usd")
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class className(
@classmethod
@property
def DANISHPIG(cls):
return cls._enum_by_value["DanishPig"]("DanishPig")
return cls("DanishPig")


def __new__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ class just_symbol(
@classmethod
@property
def GREATER_THAN_EQUALS(cls):
return cls._enum_by_value[">="](">=")
return cls(">=")

@classmethod
@property
def DOLLAR(cls):
return cls._enum_by_value["$"]("$")
return cls("$")


class array_enum(
Expand All @@ -114,12 +114,12 @@ class _items(
@classmethod
@property
def FISH(cls):
return cls._enum_by_value["fish"]("fish")
return cls("fish")

@classmethod
@property
def CRAB(cls):
return cls._enum_by_value["crab"]("crab")
return cls("crab")


def __new__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ class EnumClass(
@classmethod
@property
def _ABC(cls):
return cls._enum_by_value["_abc"]("_abc")
return cls("_abc")

@classmethod
@property
def EFG(cls):
return cls._enum_by_value["-efg"]("-efg")
return cls("-efg")

@classmethod
@property
def XYZ(cls):
return cls._enum_by_value["(xyz)"]("(xyz)")
return cls("(xyz)")
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ class enum_string(
@classmethod
@property
def UPPER(cls):
return cls._enum_by_value["UPPER"]("UPPER")
return cls("UPPER")

@classmethod
@property
def LOWER(cls):
return cls._enum_by_value["lower"]("lower")
return cls("lower")

@classmethod
@property
def EMPTY(cls):
return cls._enum_by_value[""]("")
return cls("")


class enum_string_required(
Expand All @@ -119,17 +119,17 @@ class enum_string_required(
@classmethod
@property
def UPPER(cls):
return cls._enum_by_value["UPPER"]("UPPER")
return cls("UPPER")

@classmethod
@property
def LOWER(cls):
return cls._enum_by_value["lower"]("lower")
return cls("lower")

@classmethod
@property
def EMPTY(cls):
return cls._enum_by_value[""]("")
return cls("")


class enum_integer(
Expand All @@ -145,12 +145,12 @@ class enum_integer(
@classmethod
@property
def POSITIVE_1(cls):
return cls._enum_by_value[1](1)
return cls(1)

@classmethod
@property
def NEGATIVE_1(cls):
return cls._enum_by_value[-1](-1)
return cls(-1)


class enum_number(
Expand All @@ -166,12 +166,12 @@ class enum_number(
@classmethod
@property
def POSITIVE_1_PT_1(cls):
return cls._enum_by_value[1.1](1.1)
return cls(1.1)

@classmethod
@property
def NEGATIVE_1_PT_2(cls):
return cls._enum_by_value[-1.2](-1.2)
return cls(-1.2)

@classmethod
@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class triangleType(
@classmethod
@property
def EQUILATERALTRIANGLE(cls):
return cls._enum_by_value["EquilateralTriangle"]("EquilateralTriangle")
return cls("EquilateralTriangle")


def __new__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ class IntegerEnum(
@classmethod
@property
def POSITIVE_0(cls):
return cls._enum_by_value[0](0)
return cls(0)

@classmethod
@property
def POSITIVE_1(cls):
return cls._enum_by_value[1](1)
return cls(1)

@classmethod
@property
def POSITIVE_2(cls):
return cls._enum_by_value[2](2)
return cls(2)
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ class IntegerEnumBig(
@classmethod
@property
def POSITIVE_10(cls):
return cls._enum_by_value[10](10)
return cls(10)

@classmethod
@property
def POSITIVE_11(cls):
return cls._enum_by_value[11](11)
return cls(11)

@classmethod
@property
def POSITIVE_12(cls):
return cls._enum_by_value[12](12)
return cls(12)
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ class IntegerEnumOneValue(
@classmethod
@property
def POSITIVE_0(cls):
return cls._enum_by_value[0](0)
return cls(0)
Loading