diff --git a/crates/ty_ide/src/goto_type_definition.rs b/crates/ty_ide/src/goto_type_definition.rs index 35a76b4cee..910f3ab982 100644 --- a/crates/ty_ide/src/goto_type_definition.rs +++ b/crates/ty_ide/src/goto_type_definition.rs @@ -72,7 +72,7 @@ mod tests { "#, ); - assert_snapshot!(test.goto_type_definition(), @r" + assert_snapshot!(test.goto_type_definition(), @r#" info[goto-type definition]: Go to type definition --> main.py:4:1 | @@ -82,15 +82,15 @@ mod tests { | ^^ Clicking here | info: Found 1 type definition - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ------- - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | - "); + "#); } // this is a slightly different case to the one above, @@ -137,7 +137,7 @@ mod tests { "#, ); - assert_snapshot!(test.goto_type_definition(), @r" + assert_snapshot!(test.goto_type_definition(), @r#" info[goto-type definition]: Go to type definition --> main.py:4:1 | @@ -147,16 +147,15 @@ mod tests { | ^^ Clicking here | info: Found 1 type definition - --> stdlib/typing.pyi:781:1 - | - 779 | def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ... - 780 | - 781 | Generic: type[_Generic] - | ------- - 782 | - 783 | class _ProtocolMeta(ABCMeta): - | - "); + --> stdlib/typing.pyi:1268:1 + | + 1266 | def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ... + 1267 | + 1268 | Generic: type[_Generic] + | ------- + 1269 | """Abstract base class for generic types. + | + "#); } #[test] diff --git a/crates/ty_ide/src/inlay_hints.rs b/crates/ty_ide/src/inlay_hints.rs index 59d700b191..4666637b7b 100644 --- a/crates/ty_ide/src/inlay_hints.rs +++ b/crates/ty_ide/src/inlay_hints.rs @@ -723,13 +723,13 @@ mod tests { --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:6:5 @@ -801,13 +801,13 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:10:6 @@ -881,13 +881,13 @@ mod tests { --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:8:6 @@ -919,13 +919,13 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:8:24 @@ -1061,13 +1061,13 @@ mod tests { --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:8:6 @@ -1099,13 +1099,13 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:8:24 @@ -1259,13 +1259,13 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:8:11 @@ -1297,13 +1297,13 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:8:23 @@ -1486,13 +1486,13 @@ mod tests { x4[: int], (y4[: str], z4[: int]) = (x3, (y3, z3)) --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:8:6 @@ -1524,13 +1524,13 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:8:25 @@ -1562,13 +1562,13 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:8:47 @@ -1735,13 +1735,13 @@ mod tests { w[: int] = z --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:6:5 @@ -5525,13 +5525,13 @@ mod tests { y[: Literal[1, 2, 3, "hello"] | None] = x --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:13:9 @@ -6342,13 +6342,13 @@ mod tests { a[: ] = Literal['a', 'b', 'c'] --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:351:1 + --> stdlib/typing.pyi:487:1 | - 349 | Final: _SpecialForm - 350 | - 351 | Literal: _SpecialForm + 485 | """ + 486 | + 487 | Literal: _SpecialForm | ^^^^^^^ - 352 | TypedDict: _SpecialForm + 488 | """Special typing form to define literal types (a.k.a. value types). | info: Source --> main2.py:4:20 @@ -6573,14 +6573,14 @@ mod tests { Y[: ] = N --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:615:11 - | - 613 | TypeGuard: _SpecialForm - 614 | - 615 | class NewType: - | ^^^^^^^ - 616 | """NewType creates simple unique types with almost zero runtime overhead. - | + --> stdlib/typing.pyi:1040:11 + | + 1038 | """ + 1039 | + 1040 | class NewType: + | ^^^^^^^ + 1041 | """NewType creates simple unique types with almost zero runtime overhead. + | info: Source --> main2.py:4:6 | @@ -6614,15 +6614,15 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:637:28 - | - 635 | """ - 636 | - 637 | def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm - | ^^^^ - 638 | if sys.version_info >= (3, 11): - 639 | @staticmethod - | + --> stdlib/typing.pyi:1062:28 + | + 1060 | """ + 1061 | + 1062 | def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm + | ^^^^ + 1063 | if sys.version_info >= (3, 11): + 1064 | @staticmethod + | info: Source --> main2.py:4:44 | @@ -6635,15 +6635,15 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:637:39 - | - 635 | """ - 636 | - 637 | def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm - | ^^ - 638 | if sys.version_info >= (3, 11): - 639 | @staticmethod - | + --> stdlib/typing.pyi:1062:39 + | + 1060 | """ + 1061 | + 1062 | def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm + | ^^ + 1063 | if sys.version_info >= (3, 11): + 1064 | @staticmethod + | info: Source --> main2.py:4:56 | @@ -6656,14 +6656,14 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:615:11 - | - 613 | TypeGuard: _SpecialForm - 614 | - 615 | class NewType: - | ^^^^^^^ - 616 | """NewType creates simple unique types with almost zero runtime overhead. - | + --> stdlib/typing.pyi:1040:11 + | + 1038 | """ + 1039 | + 1040 | class NewType: + | ^^^^^^^ + 1041 | """NewType creates simple unique types with almost zero runtime overhead. + | info: Source --> main2.py:6:6 | @@ -6749,7 +6749,7 @@ mod tests { Strange = Protocol[T]", ); - assert_snapshot!(test.inlay_hints(), @r" + assert_snapshot!(test.inlay_hints(), @r#" from typing import Protocol, TypeVar T = TypeVar([name=]'T') Strange[: ] = Protocol[T] @@ -6774,13 +6774,13 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:341:1 + --> stdlib/typing.pyi:346:1 | - 340 | Union: _SpecialForm - 341 | Protocol: _SpecialForm + 344 | """ + 345 | + 346 | Protocol: _SpecialForm | ^^^^^^^^ - 342 | Callable: _SpecialForm - 343 | Type: _SpecialForm + 347 | """Base class for protocol classes. | info: Source --> main2.py:4:26 @@ -6807,7 +6807,7 @@ mod tests { 4 | Strange[: ] = Protocol[T] | ^ | - "); + "#); } #[test] @@ -6823,14 +6823,14 @@ mod tests { P = ParamSpec([name=]'P') --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:552:17 + --> stdlib/typing.pyi:901:17 | - 550 | def __new__( - 551 | cls, - 552 | name: str, + 899 | def __new__( + 900 | cls, + 901 | name: str, | ^^^^ - 553 | *, - 554 | bound: Any | None = None, # AnnotationForm + 902 | *, + 903 | bound: Any | None = None, # AnnotationForm | info: Source --> main2.py:3:16 @@ -6855,14 +6855,14 @@ mod tests { A = TypeAliasType([name=]'A', [value=]str) --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:2037:26 + --> stdlib/typing.pyi:2546:26 | - 2035 | """ - 2036 | - 2037 | def __new__(cls, name: str, value: Any, *, type_params: tuple[_TypeParameter, ...] = ()) -> Self: ... + 2544 | """ + 2545 | + 2546 | def __new__(cls, name: str, value: Any, *, type_params: tuple[_TypeParameter, ...] = ()) -> Self: ... | ^^^^ - 2038 | @property - 2039 | def __value__(self) -> Any: ... # AnnotationForm + 2547 | @property + 2548 | def __value__(self) -> Any: ... # AnnotationForm | info: Source --> main2.py:3:20 @@ -6873,14 +6873,14 @@ mod tests { | info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:2037:37 + --> stdlib/typing.pyi:2546:37 | - 2035 | """ - 2036 | - 2037 | def __new__(cls, name: str, value: Any, *, type_params: tuple[_TypeParameter, ...] = ()) -> Self: ... + 2544 | """ + 2545 | + 2546 | def __new__(cls, name: str, value: Any, *, type_params: tuple[_TypeParameter, ...] = ()) -> Self: ... | ^^^^^ - 2038 | @property - 2039 | def __value__(self) -> Any: ... # AnnotationForm + 2547 | @property + 2548 | def __value__(self) -> Any: ... # AnnotationForm | info: Source --> main2.py:3:32 @@ -6905,14 +6905,14 @@ mod tests { Ts = TypeVarTuple([name=]'Ts') --------------------------------------------- info[inlay-hint-location]: Inlay Hint Target - --> stdlib/typing.pyi:412:30 + --> stdlib/typing.pyi:761:30 | - 410 | def has_default(self) -> bool: ... - 411 | if sys.version_info >= (3, 13): - 412 | def __new__(cls, name: str, *, default: Any = ...) -> Self: ... # AnnotationForm + 759 | def has_default(self) -> bool: ... + 760 | if sys.version_info >= (3, 13): + 761 | def __new__(cls, name: str, *, default: Any = ...) -> Self: ... # AnnotationForm | ^^^^ - 413 | elif sys.version_info >= (3, 12): - 414 | def __new__(cls, name: str) -> Self: ... + 762 | elif sys.version_info >= (3, 12): + 763 | def __new__(cls, name: str) -> Self: ... | info: Source --> main2.py:3:20 diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/deprecated.md_-_Tests_for_the_`@depr…_-_Syntax_(142fa2948c3c6cf1).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/deprecated.md_-_Tests_for_the_`@depr…_-_Syntax_(142fa2948c3c6cf1).snap index d8bf66cf9e..102d9d4141 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/deprecated.md_-_Tests_for_the_`@depr…_-_Syntax_(142fa2948c3c6cf1).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/deprecated.md_-_Tests_for_the_`@depr…_-_Syntax_(142fa2948c3c6cf1).snap @@ -91,14 +91,14 @@ error[missing-argument]: No argument provided for required parameter `arg` of bo 7 | from typing_extensions import deprecated | info: Parameter declared here - --> stdlib/typing_extensions.pyi:1001:28 + --> stdlib/typing_extensions.pyi:1341:28 | - 999 | stacklevel: int -1000 | def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ... -1001 | def __call__(self, arg: _T, /) -> _T: ... +1339 | stacklevel: int +1340 | def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ... +1341 | def __call__(self, arg: _T, /) -> _T: ... | ^^^^^^^ -1002 | -1003 | @final +1342 | +1343 | @final | info: rule `missing-argument` is enabled by default diff --git a/crates/ty_vendored/vendor/typeshed/source_commit.txt b/crates/ty_vendored/vendor/typeshed/source_commit.txt index 9b6271207d..c7542697bb 100644 --- a/crates/ty_vendored/vendor/typeshed/source_commit.txt +++ b/crates/ty_vendored/vendor/typeshed/source_commit.txt @@ -1 +1 @@ -3c2dbb1fde8e8d1d59b10161c8bf5fd06c0011cd +3714af2b840f476bd992f3cad8dd4886edda7712 diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/_ctypes.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/_ctypes.pyi index 39301c5f89..bbc822b2ae 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/_ctypes.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/_ctypes.pyi @@ -1,6 +1,7 @@ """Create and manipulate C compatible data types in Python.""" import _typeshed +import builtins import sys from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from abc import abstractmethod @@ -251,24 +252,50 @@ class CFuncPtr(_PointerLike, _CData, metaclass=_PyCFuncPtrType): _GetT = TypeVar("_GetT") _SetT = TypeVar("_SetT") -# This class is not exposed. It calls itself _ctypes.CField. -@final -@type_check_only -class _CField(Generic[_CT, _GetT, _SetT]): - offset: int - size: int - if sys.version_info >= (3, 10): - @overload - def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... - @overload - def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> _GetT: ... - else: - @overload - def __get__(self, instance: None, owner: type[Any] | None, /) -> Self: ... - @overload - def __get__(self, instance: Any, owner: type[Any] | None, /) -> _GetT: ... +if sys.version_info >= (3, 14): + @final + class CField(Generic[_CT, _GetT, _SetT]): + """Structure/Union member""" - def __set__(self, instance: Any, value: _SetT, /) -> None: ... + offset: int + size: int + name: str + type: builtins.type[_CT] + byte_offset: int + byte_size: int + is_bitfield: bool + bit_offset: int + bit_size: int + is_anonymous: bool + @overload + def __get__(self, instance: None, owner: builtins.type[Any] | None = None, /) -> Self: + """Return an attribute of instance, which is of type owner.""" + + @overload + def __get__(self, instance: Any, owner: builtins.type[Any] | None = None, /) -> _GetT: ... + def __set__(self, instance: Any, value: _SetT, /) -> None: + """Set an attribute of instance to value.""" + + _CField = CField + +else: + @final + @type_check_only + class _CField(Generic[_CT, _GetT, _SetT]): + offset: int + size: int + if sys.version_info >= (3, 10): + @overload + def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... + @overload + def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> _GetT: ... + else: + @overload + def __get__(self, instance: None, owner: type[Any] | None, /) -> Self: ... + @overload + def __get__(self, instance: Any, owner: type[Any] | None, /) -> _GetT: ... + + def __set__(self, instance: Any, value: _SetT, /) -> None: ... # This class is not exposed. It calls itself _ctypes.UnionType. @type_check_only diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/_thread.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/_thread.pyi index 8b63cc7ca8..cab6f108c0 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/_thread.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/_thread.pyi @@ -350,6 +350,7 @@ class _ExceptHookArgs(structseq[Any], tuple[type[BaseException], BaseException | """Thread""" _excepthook: Callable[[_ExceptHookArgs], Any] +"""Handle uncaught Thread.run() exception.""" if sys.version_info >= (3, 12): def daemon_threads_allowed() -> bool: diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/argparse.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/argparse.pyi index a17f027810..f325b1cb57 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/argparse.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/argparse.pyi @@ -172,16 +172,40 @@ class _ActionsContainer: add_argument(dest, ..., name=value, ...) add_argument(option_string, option_string, ..., name=value, ...) """ + if sys.version_info >= (3, 14): + @overload + def add_argument_group( + self, + title: str | None = None, + description: str | None = None, + *, + # argument_default's type must be valid for the arguments in the group + argument_default: Any = ..., + conflict_handler: str = ..., + ) -> _ArgumentGroup: ... + @overload + @deprecated("The `prefix_chars` parameter deprecated since Python 3.14.") + def add_argument_group( + self, + title: str | None = None, + description: str | None = None, + *, + prefix_chars: str, + argument_default: Any = ..., + conflict_handler: str = ..., + ) -> _ArgumentGroup: ... + else: + def add_argument_group( + self, + title: str | None = None, + description: str | None = None, + *, + prefix_chars: str = ..., + # argument_default's type must be valid for the arguments in the group + argument_default: Any = ..., + conflict_handler: str = ..., + ) -> _ArgumentGroup: ... - def add_argument_group( - self, - title: str | None = None, - description: str | None = None, - *, - prefix_chars: str = ..., - argument_default: Any = ..., - conflict_handler: str = ..., - ) -> _ArgumentGroup: ... def add_mutually_exclusive_group(self, *, required: bool = False) -> _MutuallyExclusiveGroup: ... def _add_action(self, action: _ActionT) -> _ActionT: ... def _remove_action(self, action: Action) -> None: ... diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/asyncio/coroutines.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/asyncio/coroutines.pyi index d1db48fb9c..16360d9bc5 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/asyncio/coroutines.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/asyncio/coroutines.pyi @@ -22,15 +22,36 @@ if sys.version_info < (3, 11): an error message is logged. """ -@overload -def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: - """Return True if func is a decorated coroutine function.""" - -@overload -def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ... -@overload -def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ... -@overload -def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ... def iscoroutine(obj: object) -> TypeIs[Coroutine[Any, Any, Any]]: """Return True if obj is a coroutine object.""" + +if sys.version_info >= (3, 11): + @overload + @deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.") + def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: + """Return True if func is a decorated coroutine function.""" + + @overload + @deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.") + def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ... + @overload + @deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.") + def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ... + @overload + @deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.") + def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ... + +else: + # Sometimes needed in Python < 3.11 due to the fact that it supports @coroutine + # which was removed in 3.11 which the inspect version doesn't support. + + @overload + def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: + """Return True if func is a decorated coroutine function.""" + + @overload + def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ... + @overload + def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ... + @overload + def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ... diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/codecs.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/codecs.pyi index 5754989a3f..e2bd1e2537 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/codecs.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/codecs.pyi @@ -14,7 +14,7 @@ from _typeshed import ReadableBuffer from abc import abstractmethod from collections.abc import Callable, Generator, Iterable from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, overload, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing_extensions import Self, TypeAlias, deprecated, disjoint_base __all__ = [ "register", @@ -248,6 +248,7 @@ def getwriter(encoding: str) -> _StreamWriter: """ +@deprecated("Deprecated since Python 3.14. Use `open()` instead.") def open( filename: str, mode: str = "r", encoding: str | None = None, errors: str = "strict", buffering: int = -1 ) -> StreamReaderWriter: diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi index 372ac39270..6163b857f6 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi @@ -25,12 +25,7 @@ if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python < __slots__ = () def __new__(cls) -> Never: ... @classonly - def singleton(cls, kind: str, module: str, name: str = "UNBOUND") -> Self: - """A non-data descriptor that makes a value only visible on the class. - - This is like the "classmethod" builtin, but does not show up on - instances of the class. It may be used as a decorator. - """ + def singleton(cls, kind: str, module: str, name: str = "UNBOUND") -> Self: ... # Sentinel types and alias that don't exist at runtime. _UnboundErrorType = NewType("_UnboundErrorType", object) diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/ctypes/__init__.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/ctypes/__init__.pyi index 03c62e5dd7..df3eadeb1f 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/ctypes/__init__.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/ctypes/__init__.pyi @@ -69,6 +69,9 @@ if sys.version_info >= (3, 14): else: from _ctypes import POINTER as POINTER, pointer as pointer +if sys.version_info >= (3, 14): + CField = _CField + DEFAULT_MODE: Final[int] class ArgumentError(Exception): ... diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/enum.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/enum.pyi index 825340e75b..99c4c56b81 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/enum.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/enum.pyi @@ -510,6 +510,7 @@ class Flag(Enum): _name_: str | None # type: ignore[assignment] _value_: int + _numeric_repr_: Callable[[int], str] @_magic_enum_attr def name(self) -> str | None: # type: ignore[override] """The name of the Enum member.""" diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/imaplib.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/imaplib.pyi index b1cd69b429..86dd012cf6 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/imaplib.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/imaplib.pyi @@ -154,7 +154,7 @@ class IMAP4: (code, [data]) = .response(code) """ - def append(self, mailbox: str, flags: str, date_time: str, message: ReadableBuffer) -> str: + def append(self, mailbox: str, flags: str, date_time: str, message: ReadableBuffer) -> tuple[str, _list[bytes]]: """Append message to named mailbox. (typ, [data]) = .append(mailbox, flags, date_time, message) diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/__init__.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/__init__.pyi index 2bd6e2883d..4f5b1cf24d 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/__init__.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/__init__.pyi @@ -65,26 +65,81 @@ __all__ = [ # These functions (really bound methods) # are all autogenerated at runtime here: https://github.com/python/cpython/blob/600c65c094b0b48704d8ec2416930648052ba715/Lib/multiprocessing/__init__.py#L23 RawValue = context._default_context.RawValue +"""Returns a shared object""" + RawArray = context._default_context.RawArray +"""Returns a shared array""" + Value = context._default_context.Value +"""Returns a synchronized shared object""" + Array = context._default_context.Array +"""Returns a synchronized shared array""" + Barrier = context._default_context.Barrier +"""Returns a barrier object""" + BoundedSemaphore = context._default_context.BoundedSemaphore +"""Returns a bounded semaphore object""" + Condition = context._default_context.Condition +"""Returns a condition object""" + Event = context._default_context.Event +"""Returns an event object""" + Lock = context._default_context.Lock +"""Returns a non-recursive lock object""" + RLock = context._default_context.RLock +"""Returns a recursive lock object""" + Semaphore = context._default_context.Semaphore +"""Returns a semaphore object""" + Pipe = context._default_context.Pipe +"""Returns two connection object connected by a pipe""" + Pool = context._default_context.Pool +"""Returns a process pool object""" + allow_connection_pickling = context._default_context.allow_connection_pickling +"""Install support for sending connections and sockets +between processes +""" + cpu_count = context._default_context.cpu_count +"""Returns the number of CPUs in the system""" + get_logger = context._default_context.get_logger +"""Return package logger -- if it does not already exist then +it is created. +""" + log_to_stderr = context._default_context.log_to_stderr +"""Turn on logging and add a handler which prints to stderr""" + Manager = context._default_context.Manager +"""Returns a manager associated with a running server process + +The managers methods such as `Lock()`, `Condition()` and `Queue()` +can be used to create shared objects. +""" + set_executable = context._default_context.set_executable +"""Sets the path to a python.exe or pythonw.exe binary used to run +child processes instead of sys.executable when using the 'spawn' +start method. Useful for people embedding Python. +""" + set_forkserver_preload = context._default_context.set_forkserver_preload +"""Set list of module names to try to load in forkserver process. +This is really just a hint. +""" + get_all_start_methods = context._default_context.get_all_start_methods +"""Returns a list of the supported start methods, default first.""" + get_start_method = context._default_context.get_start_method set_start_method = context._default_context.set_start_method get_context = context._default_context.get_context diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/forkserver.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/forkserver.pyi index 00208b1103..edd3f51e77 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/forkserver.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/forkserver.pyi @@ -64,6 +64,28 @@ def write_signed(fd: int, n: int) -> None: ... _forkserver: ForkServer ensure_running = _forkserver.ensure_running +"""Make sure that a fork server is running. + +This can be called from any process. Note that usually a child +process will just reuse the forkserver started by its parent, so +ensure_running() will do nothing. +""" + get_inherited_fds = _forkserver.get_inherited_fds +"""Return list of fds inherited from parent process. + +This returns None if the current process was not started by fork +server. +""" + connect_to_new_process = _forkserver.connect_to_new_process +"""Request forkserver to create a child process. + +Returns a pair of fds (status_r, data_w). The calling process can read +the child process's pid and (eventually) its returncode from status_r. +The calling process should write to data_w the pickled preparation and +process data. +""" + set_forkserver_preload = _forkserver.set_forkserver_preload +"""Set list of module names to try to load in forkserver process.""" diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/reduction.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/reduction.pyi index 325d472f9a..2f70663c25 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/reduction.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/reduction.pyi @@ -31,6 +31,7 @@ class ForkingPickler(pickle.Pickler): loads = pickle.loads register = ForkingPickler.register +"""Register a reduce function for a type.""" def dump(obj: Any, file: SupportsWrite[bytes], protocol: int | None = None) -> None: """Replacement for pickle.dump() using ForkingPickler.""" diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/resource_tracker.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/resource_tracker.pyi index 0f8cc7817d..6050b40258 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/resource_tracker.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/resource_tracker.pyi @@ -23,8 +23,18 @@ class ResourceTracker: _resource_tracker: ResourceTracker ensure_running = _resource_tracker.ensure_running +"""Make sure that resource tracker process is running. + +This can be run from any process. Usually a child process will use +the resource created by its parent. +""" + register = _resource_tracker.register +"""Register name of resource with resource tracker.""" + unregister = _resource_tracker.unregister +"""Unregister name of resource with resource tracker.""" + getfd = _resource_tracker.getfd def main(fd: FileDescriptorOrPath) -> None: diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/numbers.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/numbers.pyi index bc5cc69515..0c8327356a 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/numbers.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/numbers.pyi @@ -74,8 +74,7 @@ class Number(metaclass=ABCMeta): __slots__ = () @abstractmethod - def __hash__(self) -> int: - """The type of the None singleton.""" + def __hash__(self) -> int: ... # See comment at the top of the file # for why some of these return types are purposefully vague diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/optparse.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/optparse.pyi index f2cd353e92..9acee429e4 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/optparse.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/optparse.pyi @@ -348,7 +348,7 @@ class OptionContainer: callback_kwargs: dict[str, Any] | None = None, help: str | None = None, metavar: str | None = None, - **kwargs, # Allow arbitrary keyword arguments for user defined option_class + **kwargs: Any, # Allow arbitrary keyword arguments for user defined option_class ) -> Option: ... def add_options(self, option_list: Iterable[Option]) -> None: ... def destroy(self) -> None: diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/os/__init__.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/os/__init__.pyi index ba7a50c4bf..df3c7404c5 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/os/__init__.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/os/__init__.pyi @@ -2439,29 +2439,12 @@ class _wrap_close: def write(self, s: str, /) -> int: ... def writelines(self, lines: Iterable[str], /) -> None: ... -def popen(cmd: str, mode: str = "r", buffering: int = -1) -> _wrap_close: ... -def spawnl(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: - """spawnl(mode, file, *args) -> integer - - Execute file with arguments from args in a subprocess. - If mode == P_NOWAIT return the pid of the process. - If mode == P_WAIT return the process's exit code if it exits normally; - otherwise return -SIG, where SIG is the signal that killed it. - """ - -def spawnle(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: Any) -> int: # Imprecise sig - """spawnle(mode, file, *args, env) -> integer - - Execute file with arguments from args in a subprocess with the - supplied environment. - If mode == P_NOWAIT return the pid of the process. - If mode == P_WAIT return the process's exit code if it exits normally; - otherwise return -SIG, where SIG is the signal that killed it. - """ - -if sys.platform != "win32": - def spawnv(mode: int, file: StrOrBytesPath, args: _ExecVArgs) -> int: - """spawnv(mode, file, args) -> integer +if sys.version_info >= (3, 14): + @deprecated("Soft deprecated. Use the subprocess module instead.") + def popen(cmd: str, mode: str = "r", buffering: int = -1) -> _wrap_close: ... + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnl(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: + """spawnl(mode, file, *args) -> integer Execute file with arguments from args in a subprocess. If mode == P_NOWAIT return the pid of the process. @@ -2469,43 +2452,140 @@ if sys.platform != "win32": otherwise return -SIG, where SIG is the signal that killed it. """ - def spawnve(mode: int, file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> int: - """spawnve(mode, file, args, env) -> integer + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnle(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: Any) -> int: # Imprecise sig + """spawnle(mode, file, *args, env) -> integer Execute file with arguments from args in a subprocess with the - specified environment. + supplied environment. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. """ else: - def spawnv(mode: int, path: StrOrBytesPath, argv: _ExecVArgs, /) -> int: - """Execute the program specified by path in a new process. + def popen(cmd: str, mode: str = "r", buffering: int = -1) -> _wrap_close: ... + def spawnl(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: + """spawnl(mode, file, *args) -> integer - mode - Mode of process creation. - path - Path of executable file. - argv - Tuple or list of strings. + Execute file with arguments from args in a subprocess. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. """ - def spawnve(mode: int, path: StrOrBytesPath, argv: _ExecVArgs, env: _ExecEnv, /) -> int: - """Execute the program specified by path in a new process. + def spawnle(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: Any) -> int: # Imprecise sig + """spawnle(mode, file, *args, env) -> integer - mode - Mode of process creation. - path - Path of executable file. - argv - Tuple or list of strings. - env - Dictionary of strings mapping to strings. + Execute file with arguments from args in a subprocess with the + supplied environment. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. """ -def system(command: StrOrBytesPath) -> int: - """Execute the command in a subshell.""" +if sys.platform != "win32": + if sys.version_info >= (3, 14): + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnv(mode: int, file: StrOrBytesPath, args: _ExecVArgs) -> int: + """spawnv(mode, file, args) -> integer + + Execute file with arguments from args in a subprocess. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ + + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnve(mode: int, file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> int: + """spawnve(mode, file, args, env) -> integer + + Execute file with arguments from args in a subprocess with the + specified environment. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ + else: + def spawnv(mode: int, file: StrOrBytesPath, args: _ExecVArgs) -> int: + """spawnv(mode, file, args) -> integer + + Execute file with arguments from args in a subprocess. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ + + def spawnve(mode: int, file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> int: + """spawnve(mode, file, args, env) -> integer + + Execute file with arguments from args in a subprocess with the + specified environment. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ + +else: + if sys.version_info >= (3, 14): + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnv(mode: int, path: StrOrBytesPath, argv: _ExecVArgs, /) -> int: + """Execute the program specified by path in a new process. + + mode + Mode of process creation. + path + Path of executable file. + argv + Tuple or list of strings. + """ + + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnve(mode: int, path: StrOrBytesPath, argv: _ExecVArgs, env: _ExecEnv, /) -> int: + """Execute the program specified by path in a new process. + + mode + Mode of process creation. + path + Path of executable file. + argv + Tuple or list of strings. + env + Dictionary of strings mapping to strings. + """ + else: + def spawnv(mode: int, path: StrOrBytesPath, argv: _ExecVArgs, /) -> int: + """Execute the program specified by path in a new process. + + mode + Mode of process creation. + path + Path of executable file. + argv + Tuple or list of strings. + """ + + def spawnve(mode: int, path: StrOrBytesPath, argv: _ExecVArgs, env: _ExecEnv, /) -> int: + """Execute the program specified by path in a new process. + + mode + Mode of process creation. + path + Path of executable file. + argv + Tuple or list of strings. + env + Dictionary of strings mapping to strings. + """ + +if sys.version_info >= (3, 14): + @deprecated("Soft deprecated. Use the subprocess module instead.") + def system(command: StrOrBytesPath) -> int: + """Execute the command in a subshell.""" + +else: + def system(command: StrOrBytesPath) -> int: + """Execute the command in a subshell.""" @final class times_result(structseq[float], tuple[float, float, float, float, float]): @@ -2616,45 +2696,90 @@ if sys.platform == "win32": """ else: - def spawnlp(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: - """spawnlp(mode, file, *args) -> integer + if sys.version_info >= (3, 14): + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnlp(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: + """spawnlp(mode, file, *args) -> integer - Execute file (which is looked for along $PATH) with arguments from - args in a subprocess with the supplied environment. - If mode == P_NOWAIT return the pid of the process. - If mode == P_WAIT return the process's exit code if it exits normally; - otherwise return -SIG, where SIG is the signal that killed it. - """ + Execute file (which is looked for along $PATH) with arguments from + args in a subprocess with the supplied environment. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ - def spawnlpe(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: Any) -> int: # Imprecise signature - """spawnlpe(mode, file, *args, env) -> integer + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnlpe(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: Any) -> int: # Imprecise signature + """spawnlpe(mode, file, *args, env) -> integer - Execute file (which is looked for along $PATH) with arguments from - args in a subprocess with the supplied environment. - If mode == P_NOWAIT return the pid of the process. - If mode == P_WAIT return the process's exit code if it exits normally; - otherwise return -SIG, where SIG is the signal that killed it. - """ + Execute file (which is looked for along $PATH) with arguments from + args in a subprocess with the supplied environment. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ - def spawnvp(mode: int, file: StrOrBytesPath, args: _ExecVArgs) -> int: - """spawnvp(mode, file, args) -> integer + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnvp(mode: int, file: StrOrBytesPath, args: _ExecVArgs) -> int: + """spawnvp(mode, file, args) -> integer - Execute file (which is looked for along $PATH) with arguments from - args in a subprocess. - If mode == P_NOWAIT return the pid of the process. - If mode == P_WAIT return the process's exit code if it exits normally; - otherwise return -SIG, where SIG is the signal that killed it. - """ + Execute file (which is looked for along $PATH) with arguments from + args in a subprocess. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ - def spawnvpe(mode: int, file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> int: - """spawnvpe(mode, file, args, env) -> integer + @deprecated("Soft deprecated. Use the subprocess module instead.") + def spawnvpe(mode: int, file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> int: + """spawnvpe(mode, file, args, env) -> integer - Execute file (which is looked for along $PATH) with arguments from - args in a subprocess with the supplied environment. - If mode == P_NOWAIT return the pid of the process. - If mode == P_WAIT return the process's exit code if it exits normally; - otherwise return -SIG, where SIG is the signal that killed it. - """ + Execute file (which is looked for along $PATH) with arguments from + args in a subprocess with the supplied environment. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ + else: + def spawnlp(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: + """spawnlp(mode, file, *args) -> integer + + Execute file (which is looked for along $PATH) with arguments from + args in a subprocess with the supplied environment. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ + + def spawnlpe(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: Any) -> int: # Imprecise signature + """spawnlpe(mode, file, *args, env) -> integer + + Execute file (which is looked for along $PATH) with arguments from + args in a subprocess with the supplied environment. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ + + def spawnvp(mode: int, file: StrOrBytesPath, args: _ExecVArgs) -> int: + """spawnvp(mode, file, args) -> integer + + Execute file (which is looked for along $PATH) with arguments from + args in a subprocess. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ + + def spawnvpe(mode: int, file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> int: + """spawnvpe(mode, file, args, env) -> integer + + Execute file (which is looked for along $PATH) with arguments from + args in a subprocess with the supplied environment. + If mode == P_NOWAIT return the pid of the process. + If mode == P_WAIT return the process's exit code if it exits normally; + otherwise return -SIG, where SIG is the signal that killed it. + """ def wait() -> tuple[int, int]: # Unix only """Wait for completion of a child process. diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/pathlib/__init__.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/pathlib/__init__.pyi index bfd6d681e6..13586c2e61 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/pathlib/__init__.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/pathlib/__init__.pyi @@ -154,6 +154,7 @@ class PurePath(PathLike[str]): slashes. """ + @deprecated("Deprecated since Python 3.14; will be removed in Python 3.19. Use `Path.as_uri()` instead.") def as_uri(self) -> str: """Return the path as a URI.""" @@ -777,6 +778,9 @@ class Path(PurePath): ) -> Iterator[tuple[Self, list[str], list[str]]]: """Walk the directory tree from this directory, similar to os.walk().""" + def as_uri(self) -> str: + """Return the path as a URI.""" + class PosixPath(Path, PurePosixPath): """Path subclass for non-Windows systems. diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/pdb.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/pdb.pyi index 36658133ae..eb819be31d 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/pdb.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/pdb.pyi @@ -346,7 +346,7 @@ from linecache import _ModuleGlobals from rlcompleter import Completer from types import CodeType, FrameType, TracebackType from typing import IO, Any, ClassVar, Final, Literal, TypeVar -from typing_extensions import ParamSpec, Self, TypeAlias +from typing_extensions import ParamSpec, Self, TypeAlias, deprecated __all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"] if sys.version_info >= (3, 14): @@ -464,7 +464,17 @@ class Pdb(Bdb, Cmd): stack: list[tuple[FrameType, int]] curindex: int curframe: FrameType | None - curframe_locals: Mapping[str, Any] + if sys.version_info >= (3, 13): + @property + @deprecated("The frame locals reference is no longer cached. Use 'curframe.f_locals' instead.") + def curframe_locals(self) -> Mapping[str, Any]: ... + @curframe_locals.setter + @deprecated( + "Setting 'curframe_locals' no longer has any effect as of 3.14. Update the contents of 'curframe.f_locals' instead." + ) + def curframe_locals(self, value: Mapping[str, Any]) -> None: ... + else: + curframe_locals: Mapping[str, Any] if sys.version_info >= (3, 14): mode: _Mode | None colorize: bool diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/random.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/random.pyi index 1ba0e21064..c98c948700 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/random.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/random.pyi @@ -432,27 +432,227 @@ class SystemRandom(Random): _inst: Random seed = _inst.seed +"""Initialize internal state from a seed. + +The only supported seed types are None, int, float, +str, bytes, and bytearray. + +None or no argument seeds from current time or from an operating +system specific randomness source if available. + +If *a* is an int, all bits are used. + +For version 2 (the default), all of the bits are used if *a* is a str, +bytes, or bytearray. For version 1 (provided for reproducing random +sequences from older versions of Python), the algorithm for str and +bytes generates a narrower range of seeds. + +""" + random = _inst.random uniform = _inst.uniform +"""Get a random number in the range [a, b) or [a, b] depending on rounding. + +The mean (expected value) and variance of the random variable are: + + E[X] = (a + b) / 2 + Var[X] = (b - a) ** 2 / 12 + +""" + triangular = _inst.triangular +"""Triangular distribution. + +Continuous distribution bounded by given lower and upper limits, +and having a given mode value in-between. + +http://en.wikipedia.org/wiki/Triangular_distribution + +The mean (expected value) and variance of the random variable are: + + E[X] = (low + high + mode) / 3 + Var[X] = (low**2 + high**2 + mode**2 - low*high - low*mode - high*mode) / 18 + +""" + randint = _inst.randint +"""Return random integer in range [a, b], including both end points. + """ + choice = _inst.choice +"""Choose a random element from a non-empty sequence.""" + randrange = _inst.randrange +"""Choose a random item from range(stop) or range(start, stop[, step]). + +Roughly equivalent to ``choice(range(start, stop, step))`` but +supports arbitrarily large ranges and is optimized for common cases. + +""" + sample = _inst.sample +"""Chooses k unique random elements from a population sequence. + +Returns a new list containing elements from the population while +leaving the original population unchanged. The resulting list is +in selection order so that all sub-slices will also be valid random +samples. This allows raffle winners (the sample) to be partitioned +into grand prize and second place winners (the subslices). + +Members of the population need not be hashable or unique. If the +population contains repeats, then each occurrence is a possible +selection in the sample. + +Repeated elements can be specified one at a time or with the optional +counts parameter. For example: + + sample(['red', 'blue'], counts=[4, 2], k=5) + +is equivalent to: + + sample(['red', 'red', 'red', 'red', 'blue', 'blue'], k=5) + +To choose a sample from a range of integers, use range() for the +population argument. This is especially fast and space efficient +for sampling from a large population: + + sample(range(10000000), 60) + +""" + shuffle = _inst.shuffle +"""Shuffle list x in place, and return None.""" + choices = _inst.choices +"""Return a k sized list of population elements chosen with replacement. + +If the relative weights or cumulative weights are not specified, +the selections are made with equal probability. + +""" + normalvariate = _inst.normalvariate +"""Normal distribution. + +mu is the mean, and sigma is the standard deviation. + +""" + lognormvariate = _inst.lognormvariate +"""Log normal distribution. + +If you take the natural logarithm of this distribution, you'll get a +normal distribution with mean mu and standard deviation sigma. +mu can have any value, and sigma must be greater than zero. + +""" + expovariate = _inst.expovariate +"""Exponential distribution. + +lambd is 1.0 divided by the desired mean. It should be +nonzero. (The parameter would be called "lambda", but that is +a reserved word in Python.) Returned values range from 0 to +positive infinity if lambd is positive, and from negative +infinity to 0 if lambd is negative. + +The mean (expected value) and variance of the random variable are: + + E[X] = 1 / lambd + Var[X] = 1 / lambd ** 2 + +""" + vonmisesvariate = _inst.vonmisesvariate +"""Circular data distribution. + +mu is the mean angle, expressed in radians between 0 and 2*pi, and +kappa is the concentration parameter, which must be greater than or +equal to zero. If kappa is equal to zero, this distribution reduces +to a uniform random angle over the range 0 to 2*pi. + +""" + gammavariate = _inst.gammavariate +"""Gamma distribution. Not the gamma function! + +Conditions on the parameters are alpha > 0 and beta > 0. + +The probability distribution function is: + + x ** (alpha - 1) * math.exp(-x / beta) + pdf(x) = -------------------------------------- + math.gamma(alpha) * beta ** alpha + +The mean (expected value) and variance of the random variable are: + + E[X] = alpha * beta + Var[X] = alpha * beta ** 2 + +""" + gauss = _inst.gauss +"""Gaussian distribution. + +mu is the mean, and sigma is the standard deviation. This is +slightly faster than the normalvariate() function. + +Not thread-safe without a lock around calls. + +""" + if sys.version_info >= (3, 12): binomialvariate = _inst.binomialvariate + """Binomial random variable. + + Gives the number of successes for *n* independent trials + with the probability of success in each trial being *p*: + + sum(random() < p for i in range(n)) + + Returns an integer in the range: + + 0 <= X <= n + + The integer is chosen with the probability: + + P(X == k) = math.comb(n, k) * p ** k * (1 - p) ** (n - k) + + The mean (expected value) and variance of the random variable are: + + E[X] = n * p + Var[X] = n * p * (1 - p) + + """ betavariate = _inst.betavariate +"""Beta distribution. + +Conditions on the parameters are alpha > 0 and beta > 0. +Returned values range between 0 and 1. + +The mean (expected value) and variance of the random variable are: + + E[X] = alpha / (alpha + beta) + Var[X] = alpha * beta / ((alpha + beta)**2 * (alpha + beta + 1)) + +""" + paretovariate = _inst.paretovariate +"""Pareto distribution. alpha is the shape parameter.""" + weibullvariate = _inst.weibullvariate +"""Weibull distribution. + +alpha is the scale parameter and beta is the shape parameter. + +""" + getstate = _inst.getstate +"""Return internal state; can be passed to setstate() later.""" + setstate = _inst.setstate +"""Restore internal state from object returned by getstate().""" + getrandbits = _inst.getrandbits randbytes = _inst.randbytes +"""Generate n random bytes.""" diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/shutil.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/shutil.pyi index 8a79660dff..71d3735638 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/shutil.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/shutil.pyi @@ -244,6 +244,25 @@ class _RmtreeType(Protocol): ) -> None: ... rmtree: _RmtreeType +"""Recursively delete a directory tree. + +If dir_fd is not None, it should be a file descriptor open to a directory; +path will then be relative to that directory. +dir_fd may not be implemented on your platform. +If it is unavailable, using it will raise a NotImplementedError. + +If ignore_errors is set, errors are ignored; otherwise, if onexc or +onerror is set, it is called to handle the error with arguments (func, +path, exc_info) where func is platform and implementation dependent; +path is the argument to that function that caused it to fail; and +the value of exc_info describes the exception. For onexc it is the +exception instance, and for onerror it is a tuple as returned by +sys.exc_info(). If ignore_errors is false and both onexc and +onerror are None, the exception is reraised. + +onerror is deprecated and only remains for backwards compatibility. +If both onerror and onexc are set, onerror is ignored and onexc is used. +""" _CopyFn: TypeAlias = Callable[[str, str], object] | Callable[[StrPath, StrPath], object] diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/subprocess.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/subprocess.pyi index 090c41209d..402fb97ce2 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/subprocess.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/subprocess.pyi @@ -147,7 +147,7 @@ if sys.version_info >= (3, 11): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -210,7 +210,7 @@ if sys.version_info >= (3, 11): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -244,7 +244,7 @@ if sys.version_info >= (3, 11): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -278,7 +278,7 @@ if sys.version_info >= (3, 11): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -313,7 +313,7 @@ if sys.version_info >= (3, 11): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -347,7 +347,7 @@ if sys.version_info >= (3, 11): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -384,7 +384,7 @@ elif sys.version_info >= (3, 10): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -446,7 +446,7 @@ elif sys.version_info >= (3, 10): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -479,7 +479,7 @@ elif sys.version_info >= (3, 10): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -512,7 +512,7 @@ elif sys.version_info >= (3, 10): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -546,7 +546,7 @@ elif sys.version_info >= (3, 10): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -579,7 +579,7 @@ elif sys.version_info >= (3, 10): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -614,7 +614,7 @@ else: stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -674,7 +674,7 @@ else: stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -706,7 +706,7 @@ else: stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -738,7 +738,7 @@ else: stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -771,7 +771,7 @@ else: stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -803,7 +803,7 @@ else: stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -838,7 +838,7 @@ if sys.version_info >= (3, 11): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -877,7 +877,7 @@ elif sys.version_info >= (3, 10): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -914,7 +914,7 @@ else: stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -952,7 +952,7 @@ if sys.version_info >= (3, 11): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -993,7 +993,7 @@ elif sys.version_info >= (3, 10): stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1032,7 +1032,7 @@ else: stdin: _FILE = None, stdout: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1071,7 +1071,7 @@ if sys.version_info >= (3, 11): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1137,7 +1137,7 @@ if sys.version_info >= (3, 11): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1168,7 +1168,7 @@ if sys.version_info >= (3, 11): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1199,7 +1199,7 @@ if sys.version_info >= (3, 11): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1231,7 +1231,7 @@ if sys.version_info >= (3, 11): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1262,7 +1262,7 @@ if sys.version_info >= (3, 11): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1296,7 +1296,7 @@ elif sys.version_info >= (3, 10): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1361,7 +1361,7 @@ elif sys.version_info >= (3, 10): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1391,7 +1391,7 @@ elif sys.version_info >= (3, 10): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1421,7 +1421,7 @@ elif sys.version_info >= (3, 10): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1452,7 +1452,7 @@ elif sys.version_info >= (3, 10): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1482,7 +1482,7 @@ elif sys.version_info >= (3, 10): executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1514,7 +1514,7 @@ else: executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1578,7 +1578,7 @@ else: executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1607,7 +1607,7 @@ else: executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1636,7 +1636,7 @@ else: executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1666,7 +1666,7 @@ else: executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1695,7 +1695,7 @@ else: executable: StrOrBytesPath | None = None, stdin: _FILE = None, stderr: _FILE = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1840,7 +1840,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1873,7 +1873,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1904,7 +1904,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1936,7 +1936,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1967,7 +1967,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -1998,7 +1998,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2031,7 +2031,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2063,7 +2063,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2093,7 +2093,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2124,7 +2124,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2154,7 +2154,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2184,7 +2184,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2215,7 +2215,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2246,7 +2246,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2275,7 +2275,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2305,7 +2305,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2334,7 +2334,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, @@ -2363,7 +2363,7 @@ class Popen(Generic[AnyStr]): stdin: _FILE | None = None, stdout: _FILE | None = None, stderr: _FILE | None = None, - preexec_fn: Callable[[], Any] | None = None, + preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/sys/__init__.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/sys/__init__.pyi index ee3a99be81..47e9a30b98 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/sys/__init__.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/sys/__init__.pyi @@ -98,7 +98,11 @@ if sys.platform == "win32": dllhandle: int dont_write_bytecode: bool displayhook: Callable[[object], Any] +"""Print an object to sys.stdout and also save it in builtins._""" + excepthook: Callable[[type[BaseException], BaseException, TracebackType | None], Any] +"""Handle an exception by displaying it with a traceback on sys.stderr.""" + exec_prefix: str executable: str float_repr_style: Literal["short", "legacy"] @@ -159,6 +163,10 @@ _xoptions: dict[Any, Any] _UninstantiableStructseq: TypeAlias = structseq[Any] flags: _flags +"""sys.flags + +Flags provided through command line arguments or environment vars. +""" # This class is not exposed at runtime. It calls itself sys.flags. # As a tuple, it can have a length between 15 and 18. We don't model @@ -311,6 +319,12 @@ class _flags(_UninstantiableStructseq, tuple[int, ...]): """-X int_max_str_digits""" float_info: _float_info +"""sys.float_info + +A named tuple holding information about the float type. It contains low level +information about the precision and internal representation. Please study +your system's :file:`float.h` for more information. +""" # This class is not exposed at runtime. It calls itself sys.float_info. @final @@ -383,6 +397,11 @@ class _float_info(structseq[float], tuple[float, int, int, float, int, int, int, """FLT_ROUNDS -- rounding mode used for arithmetic operations""" hash_info: _hash_info +"""hash_info + +A named tuple providing parameters used for computing +hashes. The attributes are read only. +""" # This class is not exposed at runtime. It calls itself sys.hash_info. @final @@ -449,6 +468,11 @@ class _implementation: def __getattr__(self, name: str) -> Any: ... int_info: _int_info +"""sys.int_info + +A named tuple that holds information about Python's +internal representation of integers. The attributes are read only. +""" # This class is not exposed at runtime. It calls itself sys.int_info. @final @@ -507,6 +531,11 @@ class _thread_info(_UninstantiableStructseq, tuple[_ThreadInfoName, _ThreadInfoL """name and version of the thread library""" thread_info: _thread_info +"""sys.thread_info + +A named tuple holding information about the thread implementation. +""" + _ReleaseLevel: TypeAlias = Literal["alpha", "beta", "candidate", "final"] # This class is not exposed at runtime. It calls itself sys.version_info. @@ -542,6 +571,10 @@ class _version_info(_UninstantiableStructseq, tuple[int, int, int, _ReleaseLevel """Serial release number""" version_info: _version_info +"""sys.version_info + +Version information as a named tuple. +""" def call_tracing(func: Callable[..., _T], args: Any, /) -> _T: """Call func(*args), while tracing is enabled. @@ -768,6 +801,13 @@ def intern(string: LiteralString, /) -> LiteralString: def intern(string: str, /) -> str: ... # type: ignore[misc] __interactivehook__: Callable[[], object] +"""Configure readline completion on interactive prompts. + +If the readline module can be imported, the hook will set the Tab key +as completion key and register ~/.python_history as history file. +This can be overridden in the sitecustomize or usercustomize module, +or in a PYTHONSTARTUP file. +""" if sys.version_info >= (3, 13): def _is_gil_enabled() -> bool: @@ -831,6 +871,16 @@ class UnraisableHookArgs(Protocol): object: _object unraisablehook: Callable[[UnraisableHookArgs], Any] +"""Handle an unraisable exception. + +The unraisable argument has the following attributes: + +* exc_type: Exception type. +* exc_value: Exception value, can be None. +* exc_traceback: Exception traceback, can be None. +* err_msg: Error message, can be None. +* object: Object causing the exception, can be None. +""" def __unraisablehook__(unraisable: UnraisableHookArgs, /) -> Any: """Handle an unraisable exception. diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/sysconfig.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/sysconfig.pyi index 1dfb9f3cfe..78a029fef8 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/sysconfig.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/sysconfig.pyi @@ -97,7 +97,14 @@ def get_platform() -> str: For other non-POSIX platforms, currently just returns :data:`sys.platform`. """ -if sys.version_info >= (3, 11): +if sys.version_info >= (3, 12): + @overload + def is_python_build() -> bool: ... + @overload + @deprecated("The `check_home` parameter is deprecated since Python 3.12; removed in Python 3.15.") + def is_python_build(check_home: object = None) -> bool: ... + +elif sys.version_info >= (3, 11): def is_python_build(check_home: object = None) -> bool: ... else: diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/tarfile.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/tarfile.pyi index c918b0b1a5..3c6faf2fa6 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/tarfile.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/tarfile.pyi @@ -992,6 +992,46 @@ class TarFile: """ open = TarFile.open +"""Open a tar archive for reading, writing or appending. Return +an appropriate TarFile class. + +mode: +'r' or 'r:*' open for reading with transparent compression +'r:' open for reading exclusively uncompressed +'r:gz' open for reading with gzip compression +'r:bz2' open for reading with bzip2 compression +'r:xz' open for reading with lzma compression +'r:zst' open for reading with zstd compression +'a' or 'a:' open for appending, creating the file if necessary +'w' or 'w:' open for writing without compression +'w:gz' open for writing with gzip compression +'w:bz2' open for writing with bzip2 compression +'w:xz' open for writing with lzma compression +'w:zst' open for writing with zstd compression + +'x' or 'x:' create a tarfile exclusively without compression, raise + an exception if the file is already created +'x:gz' create a gzip compressed tarfile, raise an exception + if the file is already created +'x:bz2' create a bzip2 compressed tarfile, raise an exception + if the file is already created +'x:xz' create an lzma compressed tarfile, raise an exception + if the file is already created +'x:zst' create a zstd compressed tarfile, raise an exception + if the file is already created + +'r|*' open a stream of tar blocks with transparent compression +'r|' open an uncompressed stream of tar blocks for reading +'r|gz' open a gzip compressed stream of tar blocks +'r|bz2' open a bzip2 compressed stream of tar blocks +'r|xz' open an lzma compressed stream of tar blocks +'r|zst' open a zstd compressed stream of tar blocks +'w|' open an uncompressed stream for writing +'w|gz' open a gzip compressed stream for writing +'w|bz2' open a bzip2 compressed stream for writing +'w|xz' open an lzma compressed stream for writing +'w|zst' open a zstd compressed stream for writing +""" def is_tarfile(name: StrOrBytesPath | IO[bytes]) -> bool: """Return True if name points to a tar archive that we diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/threading.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/threading.pyi index 6d825444de..66531eaca5 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/threading.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/threading.pyi @@ -105,7 +105,7 @@ def main_thread() -> Thread: Python interpreter was started. """ -def settrace(func: TraceFunction) -> None: +def settrace(func: TraceFunction | None) -> None: """Set a trace function for all threads started from the threading module. The func will be passed to sys.settrace() for each thread, before its run() @@ -128,7 +128,7 @@ if sys.version_info >= (3, 12): run() method is called. """ - def settrace_all_threads(func: TraceFunction) -> None: + def settrace_all_threads(func: TraceFunction | None) -> None: """Set a trace function for all threads started from the threading module and all Python threads that are currently executing. @@ -652,8 +652,11 @@ class Event: """ excepthook: Callable[[_ExceptHookArgs], object] +"""Handle uncaught Thread.run() exception.""" + if sys.version_info >= (3, 10): __excepthook__: Callable[[_ExceptHookArgs], object] + """Handle uncaught Thread.run() exception.""" ExceptHookArgs = _ExceptHookArgs class Timer(Thread): diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/timeit.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/timeit.pyi index a24cf2c71b..b95dc427e7 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/timeit.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/timeit.pyi @@ -56,6 +56,10 @@ _Timer: TypeAlias = Callable[[], float] _Stmt: TypeAlias = str | Callable[[], object] default_timer: _Timer +"""perf_counter() -> float + +Performance counter for benchmarking. +""" class Timer: """Class for timing execution speed of small code snippets. diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/typing.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/typing.pyi index 91b0dbf4fe..6c3616a47c 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/typing.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/typing.pyi @@ -338,26 +338,375 @@ class _SpecialForm(_Final): def __ror__(self, other: Any) -> _SpecialForm: ... Union: _SpecialForm +"""Represent a union type + +E.g. for int | str +""" + Protocol: _SpecialForm +"""Base class for protocol classes. + +Protocol classes are defined as:: + + class Proto(Protocol): + def meth(self) -> int: + ... + +Such classes are primarily used with static type checkers that recognize +structural subtyping (static duck-typing). + +For example:: + + class C: + def meth(self) -> int: + return 0 + + def func(x: Proto) -> int: + return x.meth() + + func(C()) # Passes static type check + +See PEP 544 for details. Protocol classes decorated with +@typing.runtime_checkable act as simple-minded runtime protocols that check +only the presence of given attributes, ignoring their type signatures. +Protocol classes can be generic, they are defined as:: + + class GenProto[T](Protocol): + def meth(self) -> T: + ... +""" + Callable: _SpecialForm +"""Deprecated alias to collections.abc.Callable. + + Callable[[int], str] signifies a function that takes a single + parameter of type int and returns a str. + + The subscription syntax must always be used with exactly two + values: the argument list and the return type. + The argument list must be a list of types, a ParamSpec, + Concatenate or ellipsis. The return type must be a single type. + + There is no syntax to indicate optional or keyword arguments; + such function types are rarely used as callback types. + """ + Type: _SpecialForm +"""Deprecated alias to builtins.type. + + builtins.type or typing.Type can be used to annotate class objects. + For example, suppose we have the following classes:: + + class User: ... # Abstract base for User classes + class BasicUser(User): ... + class ProUser(User): ... + class TeamUser(User): ... + + And a function that takes a class argument that's a subclass of + User and returns an instance of the corresponding class:: + + def new_user[U](user_class: Type[U]) -> U: + user = user_class() + # (Here we could write the user object to a database) + return user + + joe = new_user(BasicUser) + + At this point the type checker knows that joe has type BasicUser. + """ + NoReturn: _SpecialForm +"""Special type indicating functions that never return. + +Example:: + + from typing import NoReturn + + def stop() -> NoReturn: + raise Exception('no way') + +NoReturn can also be used as a bottom type, a type that +has no values. Starting in Python 3.11, the Never type should +be used for this concept instead. Type checkers should treat the two +equivalently. +""" + ClassVar: _SpecialForm +"""Special type construct to mark class variables. + +An annotation wrapped in ClassVar indicates that a given +attribute is intended to be used as a class variable and +should not be set on instances of that class. + +Usage:: + + class Starship: + stats: ClassVar[dict[str, int]] = {} # class variable + damage: int = 10 # instance variable + +ClassVar accepts only types and cannot be further subscribed. + +Note that ClassVar is not a class itself, and should not +be used with isinstance() or issubclass(). +""" Optional: _SpecialForm +"""Optional[X] is equivalent to Union[X, None].""" + Tuple: _SpecialForm +"""Deprecated alias to builtins.tuple. + + Tuple[X, Y] is the cross-product type of X and Y. + + Example: Tuple[T1, T2] is a tuple of two elements corresponding + to type variables T1 and T2. Tuple[int, float, str] is a tuple + of an int, a float and a string. + + To specify a variable-length tuple of homogeneous type, use Tuple[T, ...]. + """ + Final: _SpecialForm +"""Special typing construct to indicate final names to type checkers. + +A final name cannot be re-assigned or overridden in a subclass. + +For example:: + + MAX_SIZE: Final = 9000 + MAX_SIZE += 1 # Error reported by type checker + + class Connection: + TIMEOUT: Final[int] = 10 + + class FastConnector(Connection): + TIMEOUT = 1 # Error reported by type checker + +There is no runtime checking of these properties. +""" Literal: _SpecialForm +"""Special typing form to define literal types (a.k.a. value types). + +This form can be used to indicate to type checkers that the corresponding +variable or function parameter has a value equivalent to the provided +literal (or one of several literals):: + + def validate_simple(data: Any) -> Literal[True]: # always returns True + ... + + MODE = Literal['r', 'rb', 'w', 'wb'] + def open_helper(file: str, mode: MODE) -> str: + ... + + open_helper('/some/path', 'r') # Passes type check + open_helper('/other/path', 'typo') # Error in type checker + +Literal[...] cannot be subclassed. At runtime, an arbitrary value +is allowed as type argument to Literal[...], but type checkers may +impose restrictions. +""" + TypedDict: _SpecialForm +"""A simple typed namespace. At runtime it is equivalent to a plain dict. + +TypedDict creates a dictionary type such that a type checker will expect all +instances to have a certain set of keys, where each key is +associated with a value of a consistent type. This expectation +is not checked at runtime. + +Usage:: + + >>> class Point2D(TypedDict): + ... x: int + ... y: int + ... label: str + ... + >>> a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK + >>> b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check + >>> Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first') + True + +The type info can be accessed via the Point2D.__annotations__ dict, and +the Point2D.__required_keys__ and Point2D.__optional_keys__ frozensets. +TypedDict supports an additional equivalent form:: + + Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) + +By default, all keys must be present in a TypedDict. It is possible +to override this by specifying totality:: + + class Point2D(TypedDict, total=False): + x: int + y: int + +This means that a Point2D TypedDict can have any of the keys omitted. A type +checker is only expected to support a literal False or True as the value of +the total argument. True is the default, and makes all items defined in the +class body be required. + +The Required and NotRequired special forms can also be used to mark +individual keys as being required or not required:: + + class Point2D(TypedDict): + x: int # the "x" key must always be present (Required is the default) + y: NotRequired[int] # the "y" key can be omitted + +See PEP 655 for more details on Required and NotRequired. + +The ReadOnly special form can be used +to mark individual keys as immutable for type checkers:: + + class DatabaseUser(TypedDict): + id: ReadOnly[int] # the "id" key must not be modified + username: str # the "username" key can be changed + +""" if sys.version_info >= (3, 11): Self: _SpecialForm + """Used to spell the type of "self" in classes. + + Example:: + + from typing import Self + + class Foo: + def return_self(self) -> Self: + ... + return self + + This is especially useful for: + - classmethods that are used as alternative constructors + - annotating an `__enter__` method which returns self + """ + Never: _SpecialForm + """The bottom type, a type that has no members. + + This can be used to define a function that should never be + called, or a function that never returns:: + + from typing import Never + + def never_call_me(arg: Never) -> None: + pass + + def int_or_str(arg: int | str) -> None: + never_call_me(arg) # type checker error + match arg: + case int(): + print("It's an int") + case str(): + print("It's a str") + case _: + never_call_me(arg) # OK, arg is of type Never + """ + Unpack: _SpecialForm + """Type unpack operator. + + The type unpack operator takes the child types from some container type, + such as `tuple[int, str]` or a `TypeVarTuple`, and 'pulls them out'. + + For example:: + + # For some generic class `Foo`: + Foo[Unpack[tuple[int, str]]] # Equivalent to Foo[int, str] + + Ts = TypeVarTuple('Ts') + # Specifies that `Bar` is generic in an arbitrary number of types. + # (Think of `Ts` as a tuple of an arbitrary number of individual + # `TypeVar`s, which the `Unpack` is 'pulling out' directly into the + # `Generic[]`.) + class Bar(Generic[Unpack[Ts]]): ... + Bar[int] # Valid + Bar[int, str] # Also valid + + From Python 3.11, this can also be done using the `*` operator:: + + Foo[*tuple[int, str]] + class Bar(Generic[*Ts]): ... + + And from Python 3.12, it can be done using built-in syntax for generics:: + + Foo[*tuple[int, str]] + class Bar[*Ts]: ... + + The operator can also be used along with a `TypedDict` to annotate + `**kwargs` in a function signature:: + + class Movie(TypedDict): + name: str + year: int + + # This function expects two keyword arguments - *name* of type `str` and + # *year* of type `int`. + def foo(**kwargs: Unpack[Movie]): ... + + Note that there is only some runtime checking of this operator. Not + everything the runtime allows may be accepted by static type checkers. + + For more information, see PEPs 646 and 692. + """ + Required: _SpecialForm + """Special typing construct to mark a TypedDict key as required. + + This is mainly useful for total=False TypedDicts. + + For example:: + + class Movie(TypedDict, total=False): + title: Required[str] + year: int + + m = Movie( + title='The Matrix', # typechecker error if key is omitted + year=1999, + ) + + There is no runtime checking that a required key is actually provided + when instantiating a related TypedDict. + """ + NotRequired: _SpecialForm + """Special typing construct to mark a TypedDict key as potentially missing. + + For example:: + + class Movie(TypedDict): + title: str + year: NotRequired[int] + + m = Movie( + title='The Matrix', # typechecker error if key is omitted + year=1999, + ) + """ + LiteralString: _SpecialForm + """Represents an arbitrary literal string. + + Example:: + + from typing import LiteralString + + def run_query(sql: LiteralString) -> None: + ... + + def caller(arbitrary_string: str, literal_string: LiteralString) -> None: + run_query("SELECT * FROM students") # OK + run_query(literal_string) # OK + run_query("SELECT * FROM " + literal_string) # OK + run_query(arbitrary_string) # type checker error + run_query( # type checker error + f"SELECT * FROM students WHERE name = {arbitrary_string}" + ) + + Only string literals and other LiteralStrings are compatible + with LiteralString. This provides a tool to help prevent + security issues such as SQL injection. + """ @final class TypeVarTuple: @@ -609,8 +958,84 @@ if sys.version_info >= (3, 10): def evaluate_default(self) -> EvaluateFunc | None: ... Concatenate: _SpecialForm + """Special form for annotating higher-order functions. + + ``Concatenate`` can be used in conjunction with ``ParamSpec`` and + ``Callable`` to represent a higher-order function which adds, removes or + transforms the parameters of a callable. + + For example:: + + Callable[Concatenate[int, P], int] + + See PEP 612 for detailed information. + """ + TypeAlias: _SpecialForm + """Special form for marking type aliases. + + Use TypeAlias to indicate that an assignment should + be recognized as a proper type alias definition by type + checkers. + + For example:: + + Predicate: TypeAlias = Callable[..., bool] + + It's invalid when used anywhere except as in the example above. + """ + TypeGuard: _SpecialForm + """Special typing construct for marking user-defined type predicate functions. + + ``TypeGuard`` can be used to annotate the return type of a user-defined + type predicate function. ``TypeGuard`` only accepts a single type argument. + At runtime, functions marked this way should return a boolean. + + ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static + type checkers to determine a more precise type of an expression within a + program's code flow. Usually type narrowing is done by analyzing + conditional code flow and applying the narrowing to a block of code. The + conditional expression here is sometimes referred to as a "type predicate". + + Sometimes it would be convenient to use a user-defined boolean function + as a type predicate. Such a function should use ``TypeGuard[...]`` or + ``TypeIs[...]`` as its return type to alert static type checkers to + this intention. ``TypeGuard`` should be used over ``TypeIs`` when narrowing + from an incompatible type (e.g., ``list[object]`` to ``list[int]``) or when + the function does not return ``True`` for all instances of the narrowed type. + + Using ``-> TypeGuard[NarrowedType]`` tells the static type checker that + for a given function: + + 1. The return value is a boolean. + 2. If the return value is ``True``, the type of its argument + is ``NarrowedType``. + + For example:: + + def is_str_list(val: list[object]) -> TypeGuard[list[str]]: + '''Determines whether all objects in the list are strings''' + return all(isinstance(x, str) for x in val) + + def func1(val: list[object]): + if is_str_list(val): + # Type of ``val`` is narrowed to ``list[str]``. + print(" ".join(val)) + else: + # Type of ``val`` remains as ``list[object]``. + print("Not a list of strings!") + + Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower + form of ``TypeA`` (it can even be a wider form) and this may lead to + type-unsafe results. The main reason is to allow for things like + narrowing ``list[object]`` to ``list[str]`` even though the latter is not + a subtype of the former, since ``list`` is invariant. The responsibility of + writing type-safe type predicates is left to the user. + + ``TypeGuard`` also works with type variables. For more information, see + PEP 647 (User-Defined Type Guards). + """ class NewType: """NewType creates simple unique types with almost zero runtime overhead. @@ -751,17 +1176,79 @@ class _Alias: def __getitem__(self, typeargs: Any) -> Any: ... List = _Alias() +"""A generic version of list.""" + Dict = _Alias() +"""A generic version of dict.""" + DefaultDict = _Alias() +"""A generic version of collections.defaultdict.""" + Set = _Alias() +"""A generic version of set.""" + FrozenSet = _Alias() +"""A generic version of frozenset.""" + Counter = _Alias() +"""A generic version of collections.Counter.""" + Deque = _Alias() +"""A generic version of collections.deque.""" + ChainMap = _Alias() +"""A generic version of collections.ChainMap.""" OrderedDict = _Alias() +"""A generic version of collections.OrderedDict.""" Annotated: _SpecialForm +"""Add context-specific metadata to a type. + +Example: Annotated[int, runtime_check.Unsigned] indicates to the +hypothetical runtime_check module that this type is an unsigned int. +Every other consumer of this type can ignore this metadata and treat +this type as int. + +The first argument to Annotated must be a valid type. + +Details: + +- It's an error to call `Annotated` with less than two arguments. +- Access the metadata via the ``__metadata__`` attribute:: + + assert Annotated[int, '$'].__metadata__ == ('$',) + +- Nested Annotated types are flattened:: + + assert Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3] + +- Instantiating an annotated type is equivalent to instantiating the +underlying type:: + + assert Annotated[C, Ann1](5) == C(5) + +- Annotated can be used as a generic type alias:: + + type Optimized[T] = Annotated[T, runtime.Optimize()] + # type checker will treat Optimized[int] + # as equivalent to Annotated[int, runtime.Optimize()] + + type OptimizedList[T] = Annotated[list[T], runtime.Optimize()] + # type checker will treat OptimizedList[int] + # as equivalent to Annotated[list[int], runtime.Optimize()] + +- Annotated cannot be used with an unpacked TypeVarTuple:: + + type Variadic[*Ts] = Annotated[*Ts, Ann1] # NOT valid + + This would be equivalent to:: + + Annotated[T1, T2, T3, ..., Ann1] + + where T1, T2 etc. are TypeVars, which would be invalid, because + only one type should be passed to Annotated. +""" # Predefined type variables. AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001 @@ -779,6 +1266,28 @@ class _Generic: def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ... Generic: type[_Generic] +"""Abstract base class for generic types. + +On Python 3.12 and newer, generic classes implicitly inherit from +Generic when they declare a parameter list after the class's name:: + + class Mapping[KT, VT]: + def __getitem__(self, key: KT) -> VT: + ... + # Etc. + +On older versions of Python, however, generic classes have to +explicitly inherit from Generic. + +After a class has been declared to be generic, it can then be used as +follows:: + + def lookup_name[KT, VT](mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: + try: + return mapping[key] + except KeyError: + return default +""" class _ProtocolMeta(ABCMeta): if sys.version_info >= (3, 12): @@ -943,11 +1452,11 @@ else: @runtime_checkable class ContextManager(AbstractContextManager[_T_co, bool | None], Protocol[_T_co]): - """An abstract base class for context managers.""" + """A generic version of contextlib.AbstractContextManager.""" @runtime_checkable class AsyncContextManager(AbstractAsyncContextManager[_T_co, bool | None], Protocol[_T_co]): - """An abstract base class for asynchronous context managers.""" + """A generic version of contextlib.AbstractAsyncContextManager.""" @runtime_checkable class Awaitable(Protocol[_T_co]): @@ -2095,4 +2604,82 @@ if sys.version_info >= (3, 13): NoDefault: _NoDefaultType TypeIs: _SpecialForm + """Special typing construct for marking user-defined type predicate functions. + + ``TypeIs`` can be used to annotate the return type of a user-defined + type predicate function. ``TypeIs`` only accepts a single type argument. + At runtime, functions marked this way should return a boolean and accept + at least one argument. + + ``TypeIs`` aims to benefit *type narrowing* -- a technique used by static + type checkers to determine a more precise type of an expression within a + program's code flow. Usually type narrowing is done by analyzing + conditional code flow and applying the narrowing to a block of code. The + conditional expression here is sometimes referred to as a "type predicate". + + Sometimes it would be convenient to use a user-defined boolean function + as a type predicate. Such a function should use ``TypeIs[...]`` or + ``TypeGuard[...]`` as its return type to alert static type checkers to + this intention. ``TypeIs`` usually has more intuitive behavior than + ``TypeGuard``, but it cannot be used when the input and output types + are incompatible (e.g., ``list[object]`` to ``list[int]``) or when the + function does not return ``True`` for all instances of the narrowed type. + + Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for + a given function: + + 1. The return value is a boolean. + 2. If the return value is ``True``, the type of its argument + is the intersection of the argument's original type and + ``NarrowedType``. + 3. If the return value is ``False``, the type of its argument + is narrowed to exclude ``NarrowedType``. + + For example:: + + from typing import assert_type, final, TypeIs + + class Parent: pass + class Child(Parent): pass + @final + class Unrelated: pass + + def is_parent(val: object) -> TypeIs[Parent]: + return isinstance(val, Parent) + + def run(arg: Child | Unrelated): + if is_parent(arg): + # Type of ``arg`` is narrowed to the intersection + # of ``Parent`` and ``Child``, which is equivalent to + # ``Child``. + assert_type(arg, Child) + else: + # Type of ``arg`` is narrowed to exclude ``Parent``, + # so only ``Unrelated`` is left. + assert_type(arg, Unrelated) + + The type inside ``TypeIs`` must be consistent with the type of the + function's argument; if it is not, static type checkers will raise + an error. An incorrectly written ``TypeIs`` function can lead to + unsound behavior in the type system; it is the user's responsibility + to write such functions in a type-safe manner. + + ``TypeIs`` also works with type variables. For more information, see + PEP 742 (Narrowing types with ``TypeIs``). + """ + ReadOnly: _SpecialForm + """A special typing construct to mark an item of a TypedDict as read-only. + + For example:: + + class Movie(TypedDict): + title: ReadOnly[str] + year: int + + def mutate_movie(m: Movie) -> None: + m["year"] = 1992 # allowed + m["title"] = "The Matrix" # typechecker error + + There is no runtime checking for this property. + """ diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/typing_extensions.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/typing_extensions.pyi index 2c42633cf9..3ba58f22ee 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/typing_extensions.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/typing_extensions.pyi @@ -213,6 +213,37 @@ _T_contra = _TypeVar("_T_contra", contravariant=True) # warn users about potential runtime exceptions when using typing.Protocol # on older versions of Python. Protocol: _SpecialForm +"""Base class for protocol classes. + +Protocol classes are defined as:: + + class Proto(Protocol): + def meth(self) -> int: + ... + +Such classes are primarily used with static type checkers that recognize +structural subtyping (static duck-typing). + +For example:: + + class C: + def meth(self) -> int: + return 0 + + def func(x: Proto) -> int: + return x.meth() + + func(C()) # Passes static type check + +See PEP 544 for details. Protocol classes decorated with +@typing.runtime_checkable act as simple-minded runtime protocols that check +only the presence of given attributes, ignoring their type signatures. +Protocol classes can be generic, they are defined as:: + + class GenProto[T](Protocol): + def meth(self) -> T: + ... +""" def runtime_checkable(cls: _TC) -> _TC: """Mark a protocol class as a runtime protocol. @@ -237,6 +268,23 @@ def runtime_checkable(cls: _TC) -> _TC: # This alias for above is kept here for backwards compatibility. runtime = runtime_checkable Final: _SpecialForm +"""Special typing construct to indicate final names to type checkers. + +A final name cannot be re-assigned or overridden in a subclass. + +For example:: + + MAX_SIZE: Final = 9000 + MAX_SIZE += 1 # Error reported by type checker + + class Connection: + TIMEOUT: Final[int] = 10 + + class FastConnector(Connection): + TIMEOUT = 1 # Error reported by type checker + +There is no runtime checking of these properties. +""" def final(f: _F) -> _F: """Decorator to indicate final methods and final classes. @@ -288,6 +336,26 @@ def disjoint_base(cls: _TC) -> _TC: """ Literal: _SpecialForm +"""Special typing form to define literal types (a.k.a. value types). + +This form can be used to indicate to type checkers that the corresponding +variable or function parameter has a value equivalent to the provided +literal (or one of several literals):: + + def validate_simple(data: Any) -> Literal[True]: # always returns True + ... + + MODE = Literal['r', 'rb', 'w', 'wb'] + def open_helper(file: str, mode: MODE) -> str: + ... + + open_helper('/some/path', 'r') # Passes type check + open_helper('/other/path', 'typo') # Error in type checker + +Literal[...] cannot be subclassed. At runtime, an arbitrary value +is allowed as type argument to Literal[...], but type checkers may +impose restrictions. +""" def IntVar(name: str) -> Any: ... # returns a new TypeVar @@ -333,6 +401,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): def __ior__(self, value: Self, /) -> Self: ... # type: ignore[misc] OrderedDict = _Alias() +"""A generic version of collections.OrderedDict.""" if sys.version_info >= (3, 13): from typing import get_type_hints as get_type_hints @@ -434,7 +503,63 @@ def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ... def get_origin(tp: AnnotationForm) -> AnnotationForm | None: ... Annotated: _SpecialForm +"""Add context-specific metadata to a type. + +Example: Annotated[int, runtime_check.Unsigned] indicates to the +hypothetical runtime_check module that this type is an unsigned int. +Every other consumer of this type can ignore this metadata and treat +this type as int. + +The first argument to Annotated must be a valid type. + +Details: + +- It's an error to call `Annotated` with less than two arguments. +- Access the metadata via the ``__metadata__`` attribute:: + + assert Annotated[int, '$'].__metadata__ == ('$',) + +- Nested Annotated types are flattened:: + + assert Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3] + +- Instantiating an annotated type is equivalent to instantiating the +underlying type:: + + assert Annotated[C, Ann1](5) == C(5) + +- Annotated can be used as a generic type alias:: + + type Optimized[T] = Annotated[T, runtime.Optimize()] + # type checker will treat Optimized[int] + # as equivalent to Annotated[int, runtime.Optimize()] + + type OptimizedList[T] = Annotated[list[T], runtime.Optimize()] + # type checker will treat OptimizedList[int] + # as equivalent to Annotated[list[int], runtime.Optimize()] + +- Annotated cannot be used with an unpacked TypeVarTuple:: + + type Variadic[*Ts] = Annotated[*Ts, Ann1] # NOT valid + + This would be equivalent to:: + + Annotated[T1, T2, T3, ..., Ann1] + + where T1, T2 etc. are TypeVars, which would be invalid, because + only one type should be passed to Annotated. +""" + _AnnotatedAlias: Any # undocumented +"""Runtime representation of an annotated type. + +At its core 'Annotated[t, dec1, dec2, ...]' is an alias for the type 't' +with extra metadata. The alias behaves like a normal typing alias. +Instantiating is the same as instantiating the underlying type; binding +it to types is also the same. + +The metadata itself is stored in a '__metadata__' attribute as a tuple. +""" # New and changed things in 3.10 if sys.version_info >= (3, 10): @@ -484,8 +609,85 @@ else: def __init__(self, origin: ParamSpec) -> None: ... Concatenate: _SpecialForm + """Special form for annotating higher-order functions. + + ``Concatenate`` can be used in conjunction with ``ParamSpec`` and + ``Callable`` to represent a higher-order function which adds, removes or + transforms the parameters of a callable. + + For example:: + + Callable[Concatenate[int, P], int] + + See PEP 612 for detailed information. + """ + TypeAlias: _SpecialForm + """Special form for marking type aliases. + + Use TypeAlias to indicate that an assignment should + be recognized as a proper type alias definition by type + checkers. + + For example:: + + Predicate: TypeAlias = Callable[..., bool] + + It's invalid when used anywhere except as in the example above. + """ + TypeGuard: _SpecialForm + """Special typing construct for marking user-defined type predicate functions. + + ``TypeGuard`` can be used to annotate the return type of a user-defined + type predicate function. ``TypeGuard`` only accepts a single type argument. + At runtime, functions marked this way should return a boolean. + + ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static + type checkers to determine a more precise type of an expression within a + program's code flow. Usually type narrowing is done by analyzing + conditional code flow and applying the narrowing to a block of code. The + conditional expression here is sometimes referred to as a "type predicate". + + Sometimes it would be convenient to use a user-defined boolean function + as a type predicate. Such a function should use ``TypeGuard[...]`` or + ``TypeIs[...]`` as its return type to alert static type checkers to + this intention. ``TypeGuard`` should be used over ``TypeIs`` when narrowing + from an incompatible type (e.g., ``list[object]`` to ``list[int]``) or when + the function does not return ``True`` for all instances of the narrowed type. + + Using ``-> TypeGuard[NarrowedType]`` tells the static type checker that + for a given function: + + 1. The return value is a boolean. + 2. If the return value is ``True``, the type of its argument + is ``NarrowedType``. + + For example:: + + def is_str_list(val: list[object]) -> TypeGuard[list[str]]: + '''Determines whether all objects in the list are strings''' + return all(isinstance(x, str) for x in val) + + def func1(val: list[object]): + if is_str_list(val): + # Type of ``val`` is narrowed to ``list[str]``. + print(" ".join(val)) + else: + # Type of ``val`` remains as ``list[object]``. + print("Not a list of strings!") + + Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower + form of ``TypeA`` (it can even be a wider form) and this may lead to + type-unsafe results. The main reason is to allow for things like + narrowing ``list[object]`` to ``list[str]`` even though the latter is not + a subtype of the former, since ``list`` is invariant. The responsibility of + writing type-safe type predicates is left to the user. + + ``TypeGuard`` also works with type variables. For more information, see + PEP 647 (User-Defined Type Guards). + """ + def is_typeddict(tp: object) -> bool: """Check if an annotation is a TypedDict class @@ -518,7 +720,44 @@ if sys.version_info >= (3, 11): ) else: Self: _SpecialForm + """Used to spell the type of "self" in classes. + + Example:: + + from typing import Self + + class Foo: + def return_self(self) -> Self: + ... + return self + + This is especially useful for: + - classmethods that are used as alternative constructors + - annotating an `__enter__` method which returns self + """ + Never: _SpecialForm + """The bottom type, a type that has no members. + + This can be used to define a function that should never be + called, or a function that never returns:: + + from typing import Never + + def never_call_me(arg: Never) -> None: + pass + + def int_or_str(arg: int | str) -> None: + never_call_me(arg) # type checker error + match arg: + case int(): + print("It's an int") + case str(): + print("It's a str") + case _: + never_call_me(arg) # OK, arg is of type Never + """ + def reveal_type(obj: _T, /) -> _T: """Reveal the inferred type of a variable. @@ -577,9 +816,110 @@ else: def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: """Return all defined overloads for *func* as a sequence.""" Required: _SpecialForm + """Special typing construct to mark a TypedDict key as required. + + This is mainly useful for total=False TypedDicts. + + For example:: + + class Movie(TypedDict, total=False): + title: Required[str] + year: int + + m = Movie( + title='The Matrix', # typechecker error if key is omitted + year=1999, + ) + + There is no runtime checking that a required key is actually provided + when instantiating a related TypedDict. + """ + NotRequired: _SpecialForm + """Special typing construct to mark a TypedDict key as potentially missing. + + For example:: + + class Movie(TypedDict): + title: str + year: NotRequired[int] + + m = Movie( + title='The Matrix', # typechecker error if key is omitted + year=1999, + ) + """ + LiteralString: _SpecialForm + """Represents an arbitrary literal string. + + Example:: + + from typing import LiteralString + + def run_query(sql: LiteralString) -> None: + ... + + def caller(arbitrary_string: str, literal_string: LiteralString) -> None: + run_query("SELECT * FROM students") # OK + run_query(literal_string) # OK + run_query("SELECT * FROM " + literal_string) # OK + run_query(arbitrary_string) # type checker error + run_query( # type checker error + f"SELECT * FROM students WHERE name = {arbitrary_string}" + ) + + Only string literals and other LiteralStrings are compatible + with LiteralString. This provides a tool to help prevent + security issues such as SQL injection. + """ + Unpack: _SpecialForm + """Type unpack operator. + + The type unpack operator takes the child types from some container type, + such as `tuple[int, str]` or a `TypeVarTuple`, and 'pulls them out'. + + For example:: + + # For some generic class `Foo`: + Foo[Unpack[tuple[int, str]]] # Equivalent to Foo[int, str] + + Ts = TypeVarTuple('Ts') + # Specifies that `Bar` is generic in an arbitrary number of types. + # (Think of `Ts` as a tuple of an arbitrary number of individual + # `TypeVar`s, which the `Unpack` is 'pulling out' directly into the + # `Generic[]`.) + class Bar(Generic[Unpack[Ts]]): ... + Bar[int] # Valid + Bar[int, str] # Also valid + + From Python 3.11, this can also be done using the `*` operator:: + + Foo[*tuple[int, str]] + class Bar(Generic[*Ts]): ... + + And from Python 3.12, it can be done using built-in syntax for generics:: + + Foo[*tuple[int, str]] + class Bar[*Ts]: ... + + The operator can also be used along with a `TypedDict` to annotate + `**kwargs` in a function signature:: + + class Movie(TypedDict): + name: str + year: int + + # This function expects two keyword arguments - *name* of type `str` and + # *year* of type `int`. + def foo(**kwargs: Unpack[Movie]): ... + + Note that there is only some runtime checking of this operator. Not + everything the runtime allows may be accepted by static type checkers. + + For more information, see PEPs 646 and 692. + """ def dataclass_transform( *, @@ -1091,7 +1431,85 @@ else: def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... ReadOnly: _SpecialForm + """A special typing construct to mark an item of a TypedDict as read-only. + + For example:: + + class Movie(TypedDict): + title: ReadOnly[str] + year: int + + def mutate_movie(m: Movie) -> None: + m["year"] = 1992 # allowed + m["title"] = "The Matrix" # typechecker error + + There is no runtime checking for this property. + """ + TypeIs: _SpecialForm + """Special typing construct for marking user-defined type predicate functions. + + ``TypeIs`` can be used to annotate the return type of a user-defined + type predicate function. ``TypeIs`` only accepts a single type argument. + At runtime, functions marked this way should return a boolean and accept + at least one argument. + + ``TypeIs`` aims to benefit *type narrowing* -- a technique used by static + type checkers to determine a more precise type of an expression within a + program's code flow. Usually type narrowing is done by analyzing + conditional code flow and applying the narrowing to a block of code. The + conditional expression here is sometimes referred to as a "type predicate". + + Sometimes it would be convenient to use a user-defined boolean function + as a type predicate. Such a function should use ``TypeIs[...]`` or + ``TypeGuard[...]`` as its return type to alert static type checkers to + this intention. ``TypeIs`` usually has more intuitive behavior than + ``TypeGuard``, but it cannot be used when the input and output types + are incompatible (e.g., ``list[object]`` to ``list[int]``) or when the + function does not return ``True`` for all instances of the narrowed type. + + Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for + a given function: + + 1. The return value is a boolean. + 2. If the return value is ``True``, the type of its argument + is the intersection of the argument's original type and + ``NarrowedType``. + 3. If the return value is ``False``, the type of its argument + is narrowed to exclude ``NarrowedType``. + + For example:: + + from typing import assert_type, final, TypeIs + + class Parent: pass + class Child(Parent): pass + @final + class Unrelated: pass + + def is_parent(val: object) -> TypeIs[Parent]: + return isinstance(val, Parent) + + def run(arg: Child | Unrelated): + if is_parent(arg): + # Type of ``arg`` is narrowed to the intersection + # of ``Parent`` and ``Child``, which is equivalent to + # ``Child``. + assert_type(arg, Child) + else: + # Type of ``arg`` is narrowed to exclude ``Parent``, + # so only ``Unrelated`` is left. + assert_type(arg, Unrelated) + + The type inside ``TypeIs`` must be consistent with the type of the + function's argument; if it is not, static type checkers will raise + an error. An incorrectly written ``TypeIs`` function can lead to + unsound behavior in the type system; it is the user's responsibility + to write such functions in a type-safe manner. + + ``TypeIs`` also works with type variables. For more information, see + PEP 742 (Narrowing types with ``TypeIs``). + """ # TypeAliasType was added in Python 3.12, but had significant changes in 3.14. if sys.version_info >= (3, 14): @@ -1141,18 +1559,7 @@ else: def __name__(self) -> str: ... # It's writable on types, but not on instances of TypeAliasType. @property - def __module__(self) -> str | None: # type: ignore[override] - """str(object='') -> str - str(bytes_or_buffer[, encoding[, errors]]) -> str - - Create a new string object from the given object. If encoding or - errors is specified, then the object must expose a data buffer - that will be decoded using the given encoding and error handler. - Otherwise, returns the result of object.__str__() (if defined) - or repr(object). - encoding defaults to 'utf-8'. - errors defaults to 'strict'. - """ + def __module__(self) -> str | None: ... # type: ignore[override] # Returns typing._GenericAlias, which isn't stubbed. def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> AnnotationForm: ... def __init_subclass__(cls, *args: Unused, **kwargs: Unused) -> NoReturn: ... @@ -1192,6 +1599,23 @@ NoExtraItems: _NoExtraItemsType # PEP 747 TypeForm: _SpecialForm +"""A special form representing the value that results from the evaluation +of a type expression. This value encodes the information supplied in the +type expression, and it represents the type described by that type expression. + +When used in a type expression, TypeForm describes a set of type form objects. +It accepts a single type argument, which must be a valid type expression. +``TypeForm[T]`` describes the set of all type form objects that represent +the type T or types that are assignable to T. + +Usage: + + def cast[T](typ: TypeForm[T], value: Any) -> T: ... + + reveal_type(cast(int, "x")) # int + +See PEP 747 for more information. +""" # PEP 649/749 if sys.version_info >= (3, 14): diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/unittest/mock.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/unittest/mock.pyi index bd8f519cc3..ecdf1741ac 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/unittest/mock.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/unittest/mock.pyi @@ -720,6 +720,77 @@ class _patcher: def stopall() -> None: ... patch: _patcher +""" +`patch` acts as a function decorator, class decorator or a context +manager. Inside the body of the function or with statement, the `target` +is patched with a `new` object. When the function/with statement exits +the patch is undone. + +If `new` is omitted, then the target is replaced with an +`AsyncMock` if the patched object is an async function or a +`MagicMock` otherwise. If `patch` is used as a decorator and `new` is +omitted, the created mock is passed in as an extra argument to the +decorated function. If `patch` is used as a context manager the created +mock is returned by the context manager. + +`target` should be a string in the form `'package.module.ClassName'`. The +`target` is imported and the specified object replaced with the `new` +object, so the `target` must be importable from the environment you are +calling `patch` from. The target is imported when the decorated function +is executed, not at decoration time. + +The `spec` and `spec_set` keyword arguments are passed to the `MagicMock` +if patch is creating one for you. + +In addition you can pass `spec=True` or `spec_set=True`, which causes +patch to pass in the object being mocked as the spec/spec_set object. + +`new_callable` allows you to specify a different class, or callable object, +that will be called to create the `new` object. By default `AsyncMock` is +used for async functions and `MagicMock` for the rest. + +A more powerful form of `spec` is `autospec`. If you set `autospec=True` +then the mock will be created with a spec from the object being replaced. +All attributes of the mock will also have the spec of the corresponding +attribute of the object being replaced. Methods and functions being +mocked will have their arguments checked and will raise a `TypeError` if +they are called with the wrong signature. For mocks replacing a class, +their return value (the 'instance') will have the same spec as the class. + +Instead of `autospec=True` you can pass `autospec=some_object` to use an +arbitrary object as the spec instead of the one being replaced. + +By default `patch` will fail to replace attributes that don't exist. If +you pass in `create=True`, and the attribute doesn't exist, patch will +create the attribute for you when the patched function is called, and +delete it again afterwards. This is useful for writing tests against +attributes that your production code creates at runtime. It is off by +default because it can be dangerous. With it switched on you can write +passing tests against APIs that don't actually exist! + +Patch can be used as a `TestCase` class decorator. It works by +decorating each test method in the class. This reduces the boilerplate +code when your test methods share a common patchings set. `patch` finds +tests by looking for method names that start with `patch.TEST_PREFIX`. +By default this is `test`, which matches the way `unittest` finds tests. +You can specify an alternative prefix by setting `patch.TEST_PREFIX`. + +Patch can be used as a context manager, with the with statement. Here the +patching applies to the indented block after the with statement. If you +use "as" then the patched object will be bound to the name after the +"as"; very useful if `patch` is creating a mock object for you. + +Patch will raise a `RuntimeError` if passed some common misspellings of +the arguments autospec and spec_set. Pass the argument `unsafe` with the +value True to disable that check. + +`patch` takes arbitrary keyword arguments. These will be passed to +`AsyncMock` if the patched object is asynchronous, to `MagicMock` +otherwise or to `new_callable` if specified. + +`patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are +available for alternate use-cases. +""" class MagicMixin(Base): def __init__(self, *args: Any, **kw: Any) -> None: ... diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/venv/__init__.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/venv/__init__.pyi index aa09f42e01..90594a8fec 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/venv/__init__.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/venv/__init__.pyi @@ -114,8 +114,7 @@ Set up a Python executable in the environment. being processed. """ def _setup_pip(self, context: SimpleNamespace) -> None: # undocumented - """Installs or upgrades pip in a virtual environment -""" + """Installs or upgrades pip in a virtual environment""" def setup_scripts(self, context: SimpleNamespace) -> None: """ Set up scripts into the created environment from a directory. @@ -181,8 +180,7 @@ if sys.version_info >= (3, 13): *, scm_ignore_files: Iterable[str] = ..., ) -> None: - """Create a virtual environment in a directory. -""" + """Create a virtual environment in a directory.""" else: def create( @@ -194,7 +192,6 @@ else: prompt: str | None = None, upgrade_deps: bool = False, ) -> None: - """Create a virtual environment in a directory. -""" + """Create a virtual environment in a directory.""" def main(args: Sequence[str] | None = None) -> None: ... diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/xml/dom/minidom.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/xml/dom/minidom.pyi index 6547439155..79d0a7aa9d 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/xml/dom/minidom.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/xml/dom/minidom.pyi @@ -432,13 +432,9 @@ class Childless: attributes: None childNodes: EmptyNodeList @property - def firstChild(self) -> None: - """The type of the None singleton.""" - + def firstChild(self) -> None: ... @property - def lastChild(self) -> None: - """The type of the None singleton.""" - + def lastChild(self) -> None: ... def appendChild(self, node: _NodesThatAreChildren | DocumentFragment) -> NoReturn: ... def hasChildNodes(self) -> Literal[False]: ... def insertBefore( @@ -460,12 +456,10 @@ class ProcessingInstruction(Childless, Node): previousSibling: _DocumentChildren | _ElementChildren | _DocumentFragmentChildren | None childNodes: EmptyNodeList @property - def firstChild(self) -> None: - """The type of the None singleton.""" - + def firstChild(self) -> None: ... @property - def lastChild(self) -> None: - """The type of the None singleton.""" + def lastChild(self) -> None: ... + namespaceURI: None prefix: None @property @@ -516,12 +510,10 @@ class Text(CharacterData): previousSibling: _DocumentFragmentChildren | _ElementChildren | _AttrChildren | None childNodes: EmptyNodeList @property - def firstChild(self) -> None: - """The type of the None singleton.""" - + def firstChild(self) -> None: ... @property - def lastChild(self) -> None: - """The type of the None singleton.""" + def lastChild(self) -> None: ... + namespaceURI: None prefix: None @property @@ -550,12 +542,10 @@ class Comment(CharacterData): previousSibling: _DocumentChildren | _ElementChildren | _DocumentFragmentChildren | None childNodes: EmptyNodeList @property - def firstChild(self) -> None: - """The type of the None singleton.""" - + def firstChild(self) -> None: ... @property - def lastChild(self) -> None: - """The type of the None singleton.""" + def lastChild(self) -> None: ... + namespaceURI: None prefix: None @property @@ -612,12 +602,10 @@ class DocumentType(Identified, Childless, Node): previousSibling: _DocumentChildren | None childNodes: EmptyNodeList @property - def firstChild(self) -> None: - """The type of the None singleton.""" - + def firstChild(self) -> None: ... @property - def lastChild(self) -> None: - """The type of the None singleton.""" + def lastChild(self) -> None: ... + namespaceURI: None prefix: None @property @@ -676,12 +664,10 @@ class Notation(Identified, Childless, Node): previousSibling: _DocumentFragmentChildren | None childNodes: EmptyNodeList @property - def firstChild(self) -> None: - """The type of the None singleton.""" - + def firstChild(self) -> None: ... @property - def lastChild(self) -> None: - """The type of the None singleton.""" + def lastChild(self) -> None: ... + namespaceURI: None prefix: None @property