Skip to content

Commit 1b9aff4

Browse files
committed
Switch to typing_extensions.Self for __new__ implementations
1 parent 81ef8aa commit 1b9aff4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/graphql/pyutils/undefined.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""The Undefined value"""
22

33
from __future__ import annotations
4+
from typing_extensions import Self
45

56
import warnings
67

@@ -12,7 +13,7 @@ class UndefinedType:
1213

1314
_instance: UndefinedType | None = None
1415

15-
def __new__(cls) -> UndefinedType:
16+
def __new__(cls) -> Self:
1617
"""Create the Undefined singleton."""
1718
if cls._instance is None:
1819
cls._instance = super().__new__(cls)

src/graphql/type/definition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
cast,
1515
overload,
1616
)
17+
from typing_extensions import Self
1718

1819
if TYPE_CHECKING:
1920
from typing import TypeAlias, TypeGuard
@@ -232,7 +233,7 @@ class GraphQLNamedType(GraphQLType):
232233

233234
reserved_types: Mapping[str, GraphQLNamedType] = {}
234235

235-
def __new__(cls, name: str, *_args: Any, **_kwargs: Any) -> GraphQLNamedType:
236+
def __new__(cls, name: str, *_args: Any, **_kwargs: Any) -> Self:
236237
"""Create a GraphQL named type."""
237238
if name in cls.reserved_types:
238239
msg = f"Redefinition of reserved type {name!r}"

0 commit comments

Comments
 (0)