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

Enable recursive type definitions #218

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/graphql/language/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Stack(NamedTuple):
idx: int
keys: tuple[Node, ...]
edits: list[tuple[int | str, Node]]
prev: Any # 'Stack' (python/mypy/issues/731)
prev: Stack


def visit(
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/pyutils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

from __future__ import annotations

from typing import Any, NamedTuple
from typing import Any, NamedTuple, Optional

__all__ = ["Path"]


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

prev: Any # Optional['Path'] (python/mypy/issues/731)
prev: Optional[Path]
Cito marked this conversation as resolved.
Show resolved Hide resolved
"""path with the previous indices"""
key: str | int
"""current index in the path (string or integer)"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ def enter_selection_set(self, selection_set: SelectionSetNode, *_args: Any) -> N
# Field name and reason.
ConflictReason: TypeAlias = Tuple[str, "ConflictReasonMessage"]
# Reason is a string, or a nested list of conflicts.
if MYPY: # recursive types not fully supported yet (/python/mypy/issues/731)
Cito marked this conversation as resolved.
Show resolved Hide resolved
ConflictReasonMessage: TypeAlias = Union[str, List]
else:
ConflictReasonMessage: TypeAlias = Union[str, List[ConflictReason]]
ConflictReasonMessage: TypeAlias = Union[str, List[ConflictReason]]
# Tuple defining a field node in a context.
NodeAndDef: TypeAlias = Tuple[GraphQLCompositeType, FieldNode, Optional[GraphQLField]]
# Dictionary of lists of those.
Expand Down
Loading