Skip to content

Commit 2a4f680

Browse files
committed
Add ForwardRef definition to typing stub.
Copied from typeshed. Fixes pytype test failure in python/typeshed#10344. PiperOrigin-RevId: 548546490
1 parent f9cf662 commit 2a4f680

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pytype/stubs/builtins/typing.pytd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,33 @@ TYPE_CHECKING = ... # type: bool
610610
class _Alias:
611611
def __getitem__(self, typeargs: Any) -> Any: ...
612612

613+
class ForwardRef:
614+
__forward_arg__: str
615+
__forward_code__: Any
616+
__forward_evaluated__: bool
617+
__forward_value__: Any | None
618+
__forward_is_argument__: bool
619+
__forward_is_class__: bool
620+
__forward_module__: Any | None
621+
if sys.version_info >= (3, 9):
622+
# The module and is_class arguments were added in later Python 3.9 versions.
623+
def __init__(self, arg: str, is_argument: bool = True, module: Any | None = None, *, is_class: bool = False) -> None: ...
624+
else:
625+
def __init__(self, arg: str, is_argument: bool = True) -> None: ...
626+
627+
if sys.version_info >= (3, 9):
628+
def _evaluate(
629+
self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None, recursive_guard: frozenset[str]
630+
) -> Any | None: ...
631+
else:
632+
def _evaluate(self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None) -> Any | None: ...
633+
634+
def __eq__(self, other: object) -> bool: ...
635+
def __hash__(self) -> int: ...
636+
if sys.version_info >= (3, 11):
637+
def __or__(self, other: Any) -> Any: ...
638+
def __ror__(self, other: Any) -> Any: ...
639+
613640
# When adding a typing construct that is not available in all runtime versions,
614641
# do *not* add a sys.version_info guard here, as that would prevent us from
615642
# reusing the definition for typing_extensions. Instead, go to

0 commit comments

Comments
 (0)