Skip to content

Commit 4f60f0e

Browse files
[ty] Sync vendored typeshed stubs (#19334)
Co-authored-by: typeshedbot <> Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
1 parent 059e90a commit 4f60f0e

File tree

649 files changed

+86265
-8539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

649 files changed

+86265
-8539
lines changed

crates/ty_ide/src/goto.rs

Lines changed: 83 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,15 @@ mod tests {
423423

424424
assert_snapshot!(test.goto_type_definition(), @r#"
425425
info[goto-type-definition]: Type definition
426-
--> stdlib/builtins.pyi:461:7
427-
|
428-
459 | def __getitem__(self, key: int, /) -> str | int | None: ...
429-
460 |
430-
461 | class str(Sequence[str]):
431-
| ^^^
432-
462 | @overload
433-
463 | def __new__(cls, object: object = ...) -> Self: ...
434-
|
426+
--> stdlib/builtins.pyi:1120:7
427+
|
428+
1118 | def __getitem__(self, key: int, /) -> str | int | None: ...
429+
1119 |
430+
1120 | class str(Sequence[str]):
431+
| ^^^
432+
1121 | """
433+
1122 | str(object='') -> str
434+
|
435435
info: Source
436436
--> main.py:4:13
437437
|
@@ -452,15 +452,15 @@ mod tests {
452452

453453
assert_snapshot!(test.goto_type_definition(), @r#"
454454
info[goto-type-definition]: Type definition
455-
--> stdlib/builtins.pyi:461:7
456-
|
457-
459 | def __getitem__(self, key: int, /) -> str | int | None: ...
458-
460 |
459-
461 | class str(Sequence[str]):
460-
| ^^^
461-
462 | @overload
462-
463 | def __new__(cls, object: object = ...) -> Self: ...
463-
|
455+
--> stdlib/builtins.pyi:1120:7
456+
|
457+
1118 | def __getitem__(self, key: int, /) -> str | int | None: ...
458+
1119 |
459+
1120 | class str(Sequence[str]):
460+
| ^^^
461+
1121 | """
462+
1122 | str(object='') -> str
463+
|
464464
info: Source
465465
--> main.py:2:22
466466
|
@@ -568,15 +568,15 @@ mod tests {
568568

569569
assert_snapshot!(test.goto_type_definition(), @r#"
570570
info[goto-type-definition]: Type definition
571-
--> stdlib/builtins.pyi:461:7
572-
|
573-
459 | def __getitem__(self, key: int, /) -> str | int | None: ...
574-
460 |
575-
461 | class str(Sequence[str]):
576-
| ^^^
577-
462 | @overload
578-
463 | def __new__(cls, object: object = ...) -> Self: ...
579-
|
571+
--> stdlib/builtins.pyi:1120:7
572+
|
573+
1118 | def __getitem__(self, key: int, /) -> str | int | None: ...
574+
1119 |
575+
1120 | class str(Sequence[str]):
576+
| ^^^
577+
1121 | """
578+
1122 | str(object='') -> str
579+
|
580580
info: Source
581581
--> main.py:4:18
582582
|
@@ -601,16 +601,16 @@ mod tests {
601601
// TODO: This should jump to `str` and not `int` because
602602
// the keyword is typed as a string. It's only the passed argument that
603603
// is an int. Navigating to `str` would match pyright's behavior.
604-
assert_snapshot!(test.goto_type_definition(), @r"
604+
assert_snapshot!(test.goto_type_definition(), @r#"
605605
info[goto-type-definition]: Type definition
606-
--> stdlib/builtins.pyi:244:7
606+
--> stdlib/builtins.pyi:365:7
607607
|
608-
242 | _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
609-
243 |
610-
244 | class int:
608+
363 | _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
609+
364 |
610+
365 | class int:
611611
| ^^^
612-
245 | @overload
613-
246 | def __new__(cls, x: ConvertibleToInt = ..., /) -> Self: ...
612+
366 | """
613+
367 | int([x]) -> integer
614614
|
615615
info: Source
616616
--> main.py:4:18
@@ -620,7 +620,7 @@ mod tests {
620620
4 | test(a= 123)
621621
| ^
622622
|
623-
");
623+
"#);
624624
}
625625

626626
#[test]
@@ -637,14 +637,14 @@ f(**kwargs<CURSOR>)
637637

638638
assert_snapshot!(test.goto_type_definition(), @r#"
639639
info[goto-type-definition]: Type definition
640-
--> stdlib/builtins.pyi:1136:7
640+
--> stdlib/builtins.pyi:3458:7
641641
|
642-
1134 | def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
643-
1135 |
644-
1136 | class dict(MutableMapping[_KT, _VT]):
642+
3456 | """
643+
3457 |
644+
3458 | class dict(MutableMapping[_KT, _VT]):
645645
| ^^^^
646-
1137 | # __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics
647-
1138 | # Also multiprocessing.managers.SyncManager.dict()
646+
3459 | """
647+
3460 | dict() -> new empty dictionary
648648
|
649649
info: Source
650650
--> main.py:6:5
@@ -666,25 +666,25 @@ f(**kwargs<CURSOR>)
666666
"#,
667667
);
668668

669-
assert_snapshot!(test.goto_type_definition(), @r"
669+
assert_snapshot!(test.goto_type_definition(), @r#"
670670
info[goto-type-definition]: Type definition
671-
--> stdlib/builtins.pyi:461:7
672-
|
673-
459 | def __getitem__(self, key: int, /) -> str | int | None: ...
674-
460 |
675-
461 | class str(Sequence[str]):
676-
| ^^^
677-
462 | @overload
678-
463 | def __new__(cls, object: object = ...) -> Self: ...
679-
|
671+
--> stdlib/builtins.pyi:1120:7
672+
|
673+
1118 | def __getitem__(self, key: int, /) -> str | int | None: ...
674+
1119 |
675+
1120 | class str(Sequence[str]):
676+
| ^^^
677+
1121 | """
678+
1122 | str(object='') -> str
679+
|
680680
info: Source
681681
--> main.py:3:17
682682
|
683683
2 | def foo(a: str):
684684
3 | a
685685
| ^
686686
|
687-
");
687+
"#);
688688
}
689689

690690
#[test]
@@ -759,17 +759,17 @@ f(**kwargs<CURSOR>)
759759
"#,
760760
);
761761

762-
assert_snapshot!(test.goto_type_definition(), @r"
762+
assert_snapshot!(test.goto_type_definition(), @r#"
763763
info[goto-type-definition]: Type definition
764-
--> stdlib/builtins.pyi:461:7
765-
|
766-
459 | def __getitem__(self, key: int, /) -> str | int | None: ...
767-
460 |
768-
461 | class str(Sequence[str]):
769-
| ^^^
770-
462 | @overload
771-
463 | def __new__(cls, object: object = ...) -> Self: ...
772-
|
764+
--> stdlib/builtins.pyi:1120:7
765+
|
766+
1118 | def __getitem__(self, key: int, /) -> str | int | None: ...
767+
1119 |
768+
1120 | class str(Sequence[str]):
769+
| ^^^
770+
1121 | """
771+
1122 | str(object='') -> str
772+
|
773773
info: Source
774774
--> main.py:4:27
775775
|
@@ -778,7 +778,7 @@ f(**kwargs<CURSOR>)
778778
4 | print(a)
779779
| ^
780780
|
781-
");
781+
"#);
782782
}
783783

784784
#[test]
@@ -790,16 +790,17 @@ f(**kwargs<CURSOR>)
790790
"#,
791791
);
792792

793-
assert_snapshot!(test.goto_type_definition(), @r"
793+
assert_snapshot!(test.goto_type_definition(), @r#"
794794
info[goto-type-definition]: Type definition
795-
--> stdlib/types.pyi:691:11
796-
|
797-
689 | if sys.version_info >= (3, 10):
798-
690 | @final
799-
691 | class NoneType:
800-
| ^^^^^^^^
801-
692 | def __bool__(self) -> Literal[False]: ...
802-
|
795+
--> stdlib/types.pyi:1073:11
796+
|
797+
1071 | if sys.version_info >= (3, 10):
798+
1072 | @final
799+
1073 | class NoneType:
800+
| ^^^^^^^^
801+
1074 | """
802+
1075 | The type of the None singleton.
803+
|
803804
info: Source
804805
--> main.py:3:17
805806
|
@@ -809,23 +810,23 @@ f(**kwargs<CURSOR>)
809810
|
810811
811812
info[goto-type-definition]: Type definition
812-
--> stdlib/builtins.pyi:461:7
813-
|
814-
459 | def __getitem__(self, key: int, /) -> str | int | None: ...
815-
460 |
816-
461 | class str(Sequence[str]):
817-
| ^^^
818-
462 | @overload
819-
463 | def __new__(cls, object: object = ...) -> Self: ...
820-
|
813+
--> stdlib/builtins.pyi:1120:7
814+
|
815+
1118 | def __getitem__(self, key: int, /) -> str | int | None: ...
816+
1119 |
817+
1120 | class str(Sequence[str]):
818+
| ^^^
819+
1121 | """
820+
1122 | str(object='') -> str
821+
|
821822
info: Source
822823
--> main.py:3:17
823824
|
824825
2 | def foo(a: str | None, b):
825826
3 | a
826827
| ^
827828
|
828-
");
829+
"#);
829830
}
830831

831832
impl CursorTest {

crates/ty_python_semantic/resources/mdtest/snapshots/invalid_argument_typ…_-_Invalid_argument_typ…_-_Test_calling_a_funct…_(3b18271a821a59b).snap

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ error[invalid-argument-type]: Argument to function `loads` is incorrect
2929
| ^ Expected `str | bytes | bytearray`, found `Literal[5]`
3030
|
3131
info: Function defined here
32-
--> stdlib/json/__init__.pyi:39:5
33-
|
34-
37 | **kwds: Any,
35-
38 | ) -> None: ...
36-
39 | def loads(
37-
| ^^^^^
38-
40 | s: str | bytes | bytearray,
39-
| -------------------------- Parameter declared here
40-
41 | *,
41-
42 | cls: type[JSONDecoder] | None = None,
42-
|
32+
--> stdlib/json/__init__.pyi:221:5
33+
|
34+
219 | """
35+
220 |
36+
221 | def loads(
37+
| ^^^^^
38+
222 | s: str | bytes | bytearray,
39+
| -------------------------- Parameter declared here
40+
223 | *,
41+
224 | cls: type[JSONDecoder] | None = None,
42+
|
4343
info: rule `invalid-argument-type` is enabled by default
4444

4545
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f64707592dd3c32f756ddeebd012acb2b072aa0d
1+
997284534f8be3159aa56c7d102ada07c2ff6f48

crates/ty_vendored/vendor/typeshed/stdlib/__future__.pyi

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,73 @@
1+
"""
2+
Record of phased-in incompatible language changes.
3+
4+
Each line is of the form:
5+
6+
FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease ","
7+
CompilerFlag ")"
8+
9+
where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples
10+
of the same form as sys.version_info:
11+
12+
(PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int
13+
PY_MINOR_VERSION, # the 1; an int
14+
PY_MICRO_VERSION, # the 0; an int
15+
PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string
16+
PY_RELEASE_SERIAL # the 3; an int
17+
)
18+
19+
OptionalRelease records the first release in which
20+
21+
from __future__ import FeatureName
22+
23+
was accepted.
24+
25+
In the case of MandatoryReleases that have not yet occurred,
26+
MandatoryRelease predicts the release in which the feature will become part
27+
of the language.
28+
29+
Else MandatoryRelease records when the feature became part of the language;
30+
in releases at or after that, modules no longer need
31+
32+
from __future__ import FeatureName
33+
34+
to use the feature in question, but may continue to use such imports.
35+
36+
MandatoryRelease may also be None, meaning that a planned feature got
37+
dropped or that the release version is undetermined.
38+
39+
Instances of class _Feature have two corresponding methods,
40+
.getOptionalRelease() and .getMandatoryRelease().
41+
42+
CompilerFlag is the (bitfield) flag that should be passed in the fourth
43+
argument to the builtin function compile() to enable the feature in
44+
dynamically compiled code. This flag is stored in the .compiler_flag
45+
attribute on _Future instances. These values must match the appropriate
46+
#defines of CO_xxx flags in Include/cpython/compile.h.
47+
48+
No feature line is ever to be deleted from this file.
49+
"""
50+
151
from typing_extensions import TypeAlias
252

353
_VersionInfo: TypeAlias = tuple[int, int, int, str, int]
454

555
class _Feature:
656
def __init__(self, optionalRelease: _VersionInfo, mandatoryRelease: _VersionInfo | None, compiler_flag: int) -> None: ...
7-
def getOptionalRelease(self) -> _VersionInfo: ...
8-
def getMandatoryRelease(self) -> _VersionInfo | None: ...
57+
def getOptionalRelease(self) -> _VersionInfo:
58+
"""
59+
Return first release in which this feature was recognized.
60+
61+
This is a 5-tuple, of the same form as sys.version_info.
62+
"""
63+
64+
def getMandatoryRelease(self) -> _VersionInfo | None:
65+
"""
66+
Return release in which this feature will become mandatory.
67+
68+
This is a 5-tuple, of the same form as sys.version_info, or, if
69+
the feature was dropped, or the release date is undetermined, is None.
70+
"""
971
compiler_flag: int
1072

1173
absolute_import: _Feature

0 commit comments

Comments
 (0)