Skip to content

Commit

Permalink
Update typing for values in EnumType.__init__ (mirumee#1040)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Edwards <me@g18e.com>
  • Loading branch information
markedwards and Mark Edwards committed Feb 22, 2023
1 parent dcb7046 commit b151684
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ariadne/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
Optional,
Tuple,
Type,
TypeVar,
Union,
cast,
Expand Down Expand Up @@ -87,7 +88,9 @@ class EnumType(SchemaBindable):
"""

def __init__(
self, name: str, values: Union[Dict[str, Any], enum.Enum, enum.IntEnum]
self,
name: str,
values: Union[Dict[str, Any], Type[enum.Enum], Type[enum.IntEnum]],
) -> None:
"""Initializes the `EnumType` with `name` and `values` mapping.
Expand Down
18 changes: 18 additions & 0 deletions tests_mypy/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from enum import Enum, IntEnum

from ariadne import EnumType


class TestEnum(Enum):
FOO = "foo"
BAR = "bar"


class TestIntEnum(IntEnum):
FOO = 0
BAR = 1


test_dict_enum_type = EnumType("TestDictEnum", {"FOO": "foo", "BAR": "bar"})
test_enum_type = EnumType("TestEnum", TestEnum)
test_int_enum_type = EnumType("TestIntEnumType", TestIntEnum)

0 comments on commit b151684

Please sign in to comment.