diff --git a/src/graphql/pyutils/path.py b/src/graphql/pyutils/path.py index 4b74ffea..cc2202c4 100644 --- a/src/graphql/pyutils/path.py +++ b/src/graphql/pyutils/path.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, NamedTuple, Optional +from typing import NamedTuple __all__ = ["Path"] @@ -10,7 +10,7 @@ class Path(NamedTuple): """A generic path of string or integer indices""" - prev: Optional[Path] + prev: Path | None """path with the previous indices""" key: str | int """current index in the path (string or integer)""" @@ -25,7 +25,7 @@ def as_list(self) -> list[str | int]: """Return a list of the path keys.""" flattened: list[str | int] = [] append = flattened.append - curr: Path = self + curr: Path | None = self while curr: append(curr.key) curr = curr.prev diff --git a/src/graphql/validation/rules/overlapping_fields_can_be_merged.py b/src/graphql/validation/rules/overlapping_fields_can_be_merged.py index 06f47e5b..b077958b 100644 --- a/src/graphql/validation/rules/overlapping_fields_can_be_merged.py +++ b/src/graphql/validation/rules/overlapping_fields_can_be_merged.py @@ -38,8 +38,6 @@ from typing_extensions import TypeAlias -MYPY = False - __all__ = ["OverlappingFieldsCanBeMergedRule"] diff --git a/tests/execution/test_executor.py b/tests/execution/test_executor.py index b75aaad5..391a1de6 100644 --- a/tests/execution/test_executor.py +++ b/tests/execution/test_executor.py @@ -308,9 +308,11 @@ def resolve_type(_val, _info, _type): prev, key, typename = path assert key == "l2" assert typename == "SomeObject" + assert prev is not None prev, key, typename = prev assert key == 0 assert typename is None + assert prev is not None prev, key, typename = prev assert key == "l1" assert typename == "SomeQuery"