Skip to content

Commit dd74d10

Browse files
authored
Enable recursive type definitions
1 parent 27e0cd0 commit dd74d10

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/graphql/language/visitor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class Stack(NamedTuple):
162162
idx: int
163163
keys: tuple[Node, ...]
164164
edits: list[tuple[int | str, Node]]
165-
prev: Any # 'Stack' (python/mypy/issues/731)
165+
prev: Stack
166166

167167

168168
def visit(

src/graphql/pyutils/path.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
from __future__ import annotations
44

5-
from typing import Any, NamedTuple
5+
from typing import Any, NamedTuple, Optional
66

77
__all__ = ["Path"]
88

99

1010
class Path(NamedTuple):
1111
"""A generic path of string or integer indices"""
1212

13-
prev: Any # Optional['Path'] (python/mypy/issues/731)
13+
prev: Optional[Path]
1414
"""path with the previous indices"""
1515
key: str | int
1616
"""current index in the path (string or integer)"""

src/graphql/validation/rules/overlapping_fields_can_be_merged.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ def enter_selection_set(self, selection_set: SelectionSetNode, *_args: Any) -> N
9898
# Field name and reason.
9999
ConflictReason: TypeAlias = Tuple[str, "ConflictReasonMessage"]
100100
# Reason is a string, or a nested list of conflicts.
101-
if MYPY: # recursive types not fully supported yet (/python/mypy/issues/731)
102-
ConflictReasonMessage: TypeAlias = Union[str, List]
103-
else:
104-
ConflictReasonMessage: TypeAlias = Union[str, List[ConflictReason]]
101+
ConflictReasonMessage: TypeAlias = Union[str, List[ConflictReason]]
105102
# Tuple defining a field node in a context.
106103
NodeAndDef: TypeAlias = Tuple[GraphQLCompositeType, FieldNode, Optional[GraphQLField]]
107104
# Dictionary of lists of those.

0 commit comments

Comments
 (0)