diff --git a/.github/workflows/sync_typeshed.yaml b/.github/workflows/sync_typeshed.yaml index cadb98cc0b..16f486f6b6 100644 --- a/.github/workflows/sync_typeshed.yaml +++ b/.github/workflows/sync_typeshed.yaml @@ -218,6 +218,11 @@ jobs: - name: Update snapshots if: ${{ success() }} run: | + cargo r \ + --profile=profiling \ + -p ty_completion_eval \ + -- all --tasks ./crates/ty_completion_eval/completion-evaluation-tasks.csv + # The `cargo insta` docs indicate that `--unreferenced=delete` might be a good option, # but from local testing it appears to just revert all changes made by `cargo insta test --accept`. # diff --git a/crates/ty_completion_eval/completion-evaluation-tasks.csv b/crates/ty_completion_eval/completion-evaluation-tasks.csv index 93b6cd4736..4250764d04 100644 --- a/crates/ty_completion_eval/completion-evaluation-tasks.csv +++ b/crates/ty_completion_eval/completion-evaluation-tasks.csv @@ -11,7 +11,7 @@ import-deprioritizes-type_check_only,main.py,2,1 import-deprioritizes-type_check_only,main.py,3,2 import-deprioritizes-type_check_only,main.py,4,3 import-keyword-completion,main.py,0,1 -internal-typeshed-hidden,main.py,0,5 +internal-typeshed-hidden,main.py,0,4 none-completion,main.py,0,2 numpy-array,main.py,0, numpy-array,main.py,1,1 diff --git a/crates/ty_ide/src/completion.rs b/crates/ty_ide/src/completion.rs index 51dd602fec..3d6a5fc78b 100644 --- a/crates/ty_ide/src/completion.rs +++ b/crates/ty_ide/src/completion.rs @@ -1206,7 +1206,6 @@ type @r" TypeError :: type :: - _NotImplementedType :: ", ); } @@ -2092,7 +2091,7 @@ C. __call__ :: bound method .__call__(...) -> Any __class__ :: __delattr__ :: def __delattr__(self, name: str, /) -> None - __dict__ :: MappingProxyType[str, Any] + __dict__ :: dict[str, Any] __dictoffset__ :: int __dir__ :: def __dir__(self) -> Iterable[str] __doc__ :: str | None @@ -2291,7 +2290,7 @@ Quux. __call__ :: bound method .__call__(...) -> Any __class__ :: __delattr__ :: def __delattr__(self, name: str, /) -> None - __dict__ :: MappingProxyType[str, Any] + __dict__ :: dict[str, Any] __dictoffset__ :: int __dir__ :: def __dir__(self) -> Iterable[str] __doc__ :: str | None @@ -2365,7 +2364,7 @@ Answer. __copy__ :: def __copy__(self) -> Self@__copy__ __deepcopy__ :: def __deepcopy__(self, memo: Any) -> Self@__deepcopy__ __delattr__ :: def __delattr__(self, name: str, /) -> None - __dict__ :: MappingProxyType[str, Any] + __dict__ :: dict[str, Any] __dictoffset__ :: int __dir__ :: def __dir__(self) -> list[str] __doc__ :: str | None diff --git a/crates/ty_ide/src/goto_definition.rs b/crates/ty_ide/src/goto_definition.rs index 81caea650f..02d2d1b9a6 100644 --- a/crates/ty_ide/src/goto_definition.rs +++ b/crates/ty_ide/src/goto_definition.rs @@ -1605,13 +1605,13 @@ a: float = 3.14 assert_snapshot!(test.goto_definition(), @r#" info[goto-definition]: Definition - --> stdlib/builtins.pyi:346:7 + --> stdlib/builtins.pyi:348:7 | - 345 | @disjoint_base - 346 | class int: + 347 | @disjoint_base + 348 | class int: | ^^^ - 347 | """int([x]) -> integer - 348 | int(x, base=10) -> integer + 349 | """int([x]) -> integer + 350 | int(x, base=10) -> integer | info: Source --> main.py:2:4 @@ -1621,12 +1621,12 @@ a: float = 3.14 | info[goto-definition]: Definition - --> stdlib/builtins.pyi:659:7 + --> stdlib/builtins.pyi:661:7 | - 658 | @disjoint_base - 659 | class float: + 660 | @disjoint_base + 661 | class float: | ^^^^^ - 660 | """Convert a string or number to a floating-point number, if possible.""" + 662 | """Convert a string or number to a floating-point number, if possible.""" | info: Source --> main.py:2:4 @@ -1650,13 +1650,13 @@ a: complex = 3.14 assert_snapshot!(test.goto_definition(), @r#" info[goto-definition]: Definition - --> stdlib/builtins.pyi:346:7 + --> stdlib/builtins.pyi:348:7 | - 345 | @disjoint_base - 346 | class int: + 347 | @disjoint_base + 348 | class int: | ^^^ - 347 | """int([x]) -> integer - 348 | int(x, base=10) -> integer + 349 | """int([x]) -> integer + 350 | int(x, base=10) -> integer | info: Source --> main.py:2:4 @@ -1666,12 +1666,12 @@ a: complex = 3.14 | info[goto-definition]: Definition - --> stdlib/builtins.pyi:659:7 + --> stdlib/builtins.pyi:661:7 | - 658 | @disjoint_base - 659 | class float: + 660 | @disjoint_base + 661 | class float: | ^^^^^ - 660 | """Convert a string or number to a floating-point number, if possible.""" + 662 | """Convert a string or number to a floating-point number, if possible.""" | info: Source --> main.py:2:4 @@ -1681,12 +1681,12 @@ a: complex = 3.14 | info[goto-definition]: Definition - --> stdlib/builtins.pyi:820:7 + --> stdlib/builtins.pyi:822:7 | - 819 | @disjoint_base - 820 | class complex: + 821 | @disjoint_base + 822 | class complex: | ^^^^^^^ - 821 | """Create a complex number from a string or numbers. + 823 | """Create a complex number from a string or numbers. | info: Source --> main.py:2:4 diff --git a/crates/ty_ide/src/goto_type_definition.rs b/crates/ty_ide/src/goto_type_definition.rs index 7d86743af4..53e366cd49 100644 --- a/crates/ty_ide/src/goto_type_definition.rs +++ b/crates/ty_ide/src/goto_type_definition.rs @@ -199,13 +199,13 @@ mod tests { assert_snapshot!(test.goto_type_definition(), @r#" info[goto-type-definition]: Type definition - --> stdlib/builtins.pyi:913:7 + --> stdlib/builtins.pyi:915:7 | - 912 | @disjoint_base - 913 | class str(Sequence[str]): + 914 | @disjoint_base + 915 | class str(Sequence[str]): | ^^^ - 914 | """str(object='') -> str - 915 | str(bytes_or_buffer[, encoding[, errors]]) -> str + 916 | """str(object='') -> str + 917 | str(bytes_or_buffer[, encoding[, errors]]) -> str | info: Source --> main.py:4:1 @@ -227,13 +227,13 @@ mod tests { assert_snapshot!(test.goto_type_definition(), @r#" info[goto-type-definition]: Type definition - --> stdlib/builtins.pyi:913:7 + --> stdlib/builtins.pyi:915:7 | - 912 | @disjoint_base - 913 | class str(Sequence[str]): + 914 | @disjoint_base + 915 | class str(Sequence[str]): | ^^^ - 914 | """str(object='') -> str - 915 | str(bytes_or_buffer[, encoding[, errors]]) -> str + 916 | """str(object='') -> str + 917 | str(bytes_or_buffer[, encoding[, errors]]) -> str | info: Source --> main.py:2:10 @@ -334,13 +334,13 @@ mod tests { assert_snapshot!(test.goto_type_definition(), @r#" info[goto-type-definition]: Type definition - --> stdlib/builtins.pyi:913:7 + --> stdlib/builtins.pyi:915:7 | - 912 | @disjoint_base - 913 | class str(Sequence[str]): + 914 | @disjoint_base + 915 | class str(Sequence[str]): | ^^^ - 914 | """str(object='') -> str - 915 | str(bytes_or_buffer[, encoding[, errors]]) -> str + 916 | """str(object='') -> str + 917 | str(bytes_or_buffer[, encoding[, errors]]) -> str | info: Source --> main.py:4:6 @@ -368,13 +368,13 @@ mod tests { // is an int. Navigating to `str` would match pyright's behavior. assert_snapshot!(test.goto_type_definition(), @r#" info[goto-type-definition]: Type definition - --> stdlib/builtins.pyi:346:7 + --> stdlib/builtins.pyi:348:7 | - 345 | @disjoint_base - 346 | class int: + 347 | @disjoint_base + 348 | class int: | ^^^ - 347 | """int([x]) -> integer - 348 | int(x, base=10) -> integer + 349 | """int([x]) -> integer + 350 | int(x, base=10) -> integer | info: Source --> main.py:4:6 @@ -401,13 +401,13 @@ f(**kwargs) assert_snapshot!(test.goto_type_definition(), @r#" info[goto-type-definition]: Type definition - --> stdlib/builtins.pyi:2918:7 + --> stdlib/builtins.pyi:2920:7 | - 2917 | @disjoint_base - 2918 | class dict(MutableMapping[_KT, _VT]): + 2919 | @disjoint_base + 2920 | class dict(MutableMapping[_KT, _VT]): | ^^^^ - 2919 | """dict() -> new empty dictionary - 2920 | dict(mapping) -> new dictionary initialized from a mapping object's + 2921 | """dict() -> new empty dictionary + 2922 | dict(mapping) -> new dictionary initialized from a mapping object's | info: Source --> main.py:6:5 @@ -431,13 +431,13 @@ f(**kwargs) assert_snapshot!(test.goto_type_definition(), @r#" info[goto-type-definition]: Type definition - --> stdlib/builtins.pyi:913:7 + --> stdlib/builtins.pyi:915:7 | - 912 | @disjoint_base - 913 | class str(Sequence[str]): + 914 | @disjoint_base + 915 | class str(Sequence[str]): | ^^^ - 914 | """str(object='') -> str - 915 | str(bytes_or_buffer[, encoding[, errors]]) -> str + 916 | """str(object='') -> str + 917 | str(bytes_or_buffer[, encoding[, errors]]) -> str | info: Source --> main.py:3:5 @@ -523,13 +523,13 @@ f(**kwargs) assert_snapshot!(test.goto_type_definition(), @r#" info[goto-type-definition]: Type definition - --> stdlib/builtins.pyi:913:7 + --> stdlib/builtins.pyi:915:7 | - 912 | @disjoint_base - 913 | class str(Sequence[str]): + 914 | @disjoint_base + 915 | class str(Sequence[str]): | ^^^ - 914 | """str(object='') -> str - 915 | str(bytes_or_buffer[, encoding[, errors]]) -> str + 916 | """str(object='') -> str + 917 | str(bytes_or_buffer[, encoding[, errors]]) -> str | info: Source --> main.py:4:15 @@ -570,13 +570,13 @@ f(**kwargs) | info[goto-type-definition]: Type definition - --> stdlib/builtins.pyi:913:7 + --> stdlib/builtins.pyi:915:7 | - 912 | @disjoint_base - 913 | class str(Sequence[str]): + 914 | @disjoint_base + 915 | class str(Sequence[str]): | ^^^ - 914 | """str(object='') -> str - 915 | str(bytes_or_buffer[, encoding[, errors]]) -> str + 916 | """str(object='') -> str + 917 | str(bytes_or_buffer[, encoding[, errors]]) -> str | info: Source --> main.py:3:5 diff --git a/crates/ty_python_semantic/resources/mdtest/call/builtins.md b/crates/ty_python_semantic/resources/mdtest/call/builtins.md index 8de3e77d77..742d275e3d 100644 --- a/crates/ty_python_semantic/resources/mdtest/call/builtins.md +++ b/crates/ty_python_semantic/resources/mdtest/call/builtins.md @@ -197,3 +197,9 @@ isinstance("", t.ClassVar) # error: [invalid-argument-type] isinstance("", t.Final) # error: [invalid-argument-type] isinstance("", t.Any) # error: [invalid-argument-type] ``` + +## The builtin `NotImplemented` constant is not callable + +```py +NotImplemented() # error: [call-non-callable] +``` diff --git a/crates/ty_python_semantic/resources/mdtest/function/return_type.md b/crates/ty_python_semantic/resources/mdtest/function/return_type.md index 284a2dd475..b985ddfe3d 100644 --- a/crates/ty_python_semantic/resources/mdtest/function/return_type.md +++ b/crates/ty_python_semantic/resources/mdtest/function/return_type.md @@ -466,11 +466,23 @@ def f(cond: bool) -> int: return "hello" if cond else NotImplemented ``` +`NotImplemented` is only special-cased for return types (mirroring the way the interpreter applies +special casing for the symbol at runtime). It is not generally considered assignable to every other +type: + +```py +# Other type checkers do not emit an error here, +# but this is likely not a deliberate feature they've implemented; +# it's probably because `NotImplementedType` inherits from `Any` +# according to typeshed. We override typeshed's incorrect MRO +# for more precise type inference. +x: int = NotImplemented # error: [invalid-assignment] +``` + ### Python 3.10+ -Unlike Ellipsis, `_NotImplementedType` remains in `builtins.pyi` regardless of the Python version. -Even if `builtins._NotImplementedType` is fully replaced by `types.NotImplementedType` in the -future, it should still work as expected. +We correctly understand the semantics of `NotImplemented` on all Python versions, even though the +class `types.NotImplementedType` is only exposed in the `types` module on Python 3.10+. ```toml [environment] diff --git a/crates/ty_python_semantic/resources/mdtest/mro.md b/crates/ty_python_semantic/resources/mdtest/mro.md index 761fb9892d..b158cbb62b 100644 --- a/crates/ty_python_semantic/resources/mdtest/mro.md +++ b/crates/ty_python_semantic/resources/mdtest/mro.md @@ -717,3 +717,17 @@ class F[T](F(), F): ... # error: [cyclic-class-definition] reveal_type(F.__class__) # revealed: type[Unknown] reveal_mro(F) # revealed: (, Unknown, ) ``` + +## `builtins.NotImplemented` + +Typeshed tells us that `NotImplementedType` inherits from `Any`, but that causes more problems for +us than it fixes. We override typeshed here so that we understand `NotImplementedType` as inheriting +directly from `object` (as it does at runtime). + +```py +import types +from ty_extensions import reveal_mro + +reveal_mro(types.NotImplementedType) # revealed: (, ) +reveal_mro(type(NotImplemented)) # revealed: (, ) +``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/invalid_await.md_-_Invalid_await_diagno…_-_Basic_(f15db7dc447d0795).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/invalid_await.md_-_Invalid_await_diagno…_-_Basic_(f15db7dc447d0795).snap index 312f3209c5..b6897c6cb1 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/invalid_await.md_-_Invalid_await_diagno…_-_Basic_(f15db7dc447d0795).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/invalid_await.md_-_Invalid_await_diagno…_-_Basic_(f15db7dc447d0795).snap @@ -26,13 +26,13 @@ error[invalid-await]: `Literal[1]` is not awaitable 2 | await 1 # error: [invalid-await] | ^ | - ::: stdlib/builtins.pyi:346:7 + ::: stdlib/builtins.pyi:348:7 | -345 | @disjoint_base -346 | class int: +347 | @disjoint_base +348 | class int: | --- type defined here -347 | """int([x]) -> integer -348 | int(x, base=10) -> integer +349 | """int([x]) -> integer +350 | int(x, base=10) -> integer | info: `__await__` is missing info: rule `invalid-await` is enabled by default diff --git a/crates/ty_python_semantic/src/types/class.rs b/crates/ty_python_semantic/src/types/class.rs index ca83e6d981..e665119245 100644 --- a/crates/ty_python_semantic/src/types/class.rs +++ b/crates/ty_python_semantic/src/types/class.rs @@ -4564,7 +4564,15 @@ impl KnownClass { "ellipsis" } } - Self::NotImplementedType => "_NotImplementedType", + Self::NotImplementedType => { + // Exposed as `types.NotImplementedType` on Python >=3.10; + // backported as `builtins._NotImplementedType` by typeshed on Python <=3.9 + if Program::get(db).python_version(db) >= PythonVersion::PY310 { + "NotImplementedType" + } else { + "_NotImplementedType" + } + } Self::Field => "Field", Self::KwOnly => "KW_ONLY", Self::InitVar => "InitVar", @@ -4866,7 +4874,15 @@ impl KnownClass { KnownModule::Builtins } } - Self::NotImplementedType => KnownModule::Builtins, + Self::NotImplementedType => { + // Exposed as `types.NotImplementedType` on Python >=3.10; + // backported as `builtins._NotImplementedType` by typeshed on Python <=3.9 + if Program::get(db).python_version(db) >= PythonVersion::PY310 { + KnownModule::Types + } else { + KnownModule::Builtins + } + } Self::ChainMap | Self::Counter | Self::DefaultDict @@ -5136,7 +5152,12 @@ impl KnownClass { "EllipsisType" if Program::get(db).python_version(db) >= PythonVersion::PY310 => { &[Self::EllipsisType] } - "_NotImplementedType" => &[Self::NotImplementedType], + "_NotImplementedType" if Program::get(db).python_version(db) <= PythonVersion::PY39 => { + &[Self::NotImplementedType] + } + "NotImplementedType" if Program::get(db).python_version(db) >= PythonVersion::PY310 => { + &[Self::NotImplementedType] + } "Field" => &[Self::Field], "KW_ONLY" => &[Self::KwOnly], "InitVar" => &[Self::InitVar], diff --git a/crates/ty_python_semantic/src/types/mro.rs b/crates/ty_python_semantic/src/types/mro.rs index dffd166fe0..21501060da 100644 --- a/crates/ty_python_semantic/src/types/mro.rs +++ b/crates/ty_python_semantic/src/types/mro.rs @@ -7,7 +7,7 @@ use rustc_hash::FxBuildHasher; use crate::Db; use crate::types::class_base::ClassBase; use crate::types::generics::Specialization; -use crate::types::{ClassLiteral, ClassType, KnownInstanceType, SpecialFormType, Type}; +use crate::types::{ClassLiteral, ClassType, KnownClass, KnownInstanceType, SpecialFormType, Type}; /// The inferred method resolution order of a given class. /// @@ -52,6 +52,11 @@ impl<'db> Mro<'db> { specialization: Option>, ) -> Result> { let class = class_literal.apply_optional_specialization(db, specialization); + // Special-case `NotImplementedType`: typeshed says that it inherits from `Any`, + // but this causes more problems than it fixes. + if class_literal.is_known(db, KnownClass::NotImplementedType) { + return Ok(Self::from([ClassBase::Class(class), ClassBase::object(db)])); + } Self::of_class_impl(db, class, class_literal.explicit_bases(db), specialization) .map_err(|err| err.into_mro_error(db, class)) } diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import.snap b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import.snap index 0ded3aa1ee..0b1f8ad282 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import.snap @@ -6,7 +6,7 @@ expression: completions { "label": "Literal (import typing)", "kind": 6, - "sortText": " 43", + "sortText": " 50", "insertText": "Literal", "additionalTextEdits": [ { @@ -27,7 +27,7 @@ expression: completions { "label": "Literal (import typing_extensions)", "kind": 6, - "sortText": " 44", + "sortText": " 51", "insertText": "Literal", "additionalTextEdits": [ { @@ -48,7 +48,7 @@ expression: completions { "label": "LiteralString (import typing)", "kind": 6, - "sortText": " 45", + "sortText": " 52", "insertText": "LiteralString", "additionalTextEdits": [ { @@ -69,7 +69,7 @@ expression: completions { "label": "LiteralString (import typing_extensions)", "kind": 6, - "sortText": " 46", + "sortText": " 53", "insertText": "LiteralString", "additionalTextEdits": [ { diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_docstring.snap b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_docstring.snap index 0ded3aa1ee..0b1f8ad282 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_docstring.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_docstring.snap @@ -6,7 +6,7 @@ expression: completions { "label": "Literal (import typing)", "kind": 6, - "sortText": " 43", + "sortText": " 50", "insertText": "Literal", "additionalTextEdits": [ { @@ -27,7 +27,7 @@ expression: completions { "label": "Literal (import typing_extensions)", "kind": 6, - "sortText": " 44", + "sortText": " 51", "insertText": "Literal", "additionalTextEdits": [ { @@ -48,7 +48,7 @@ expression: completions { "label": "LiteralString (import typing)", "kind": 6, - "sortText": " 45", + "sortText": " 52", "insertText": "LiteralString", "additionalTextEdits": [ { @@ -69,7 +69,7 @@ expression: completions { "label": "LiteralString (import typing_extensions)", "kind": 6, - "sortText": " 46", + "sortText": " 53", "insertText": "LiteralString", "additionalTextEdits": [ { diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_from_future.snap b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_from_future.snap index 0ded3aa1ee..0b1f8ad282 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_from_future.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_from_future.snap @@ -6,7 +6,7 @@ expression: completions { "label": "Literal (import typing)", "kind": 6, - "sortText": " 43", + "sortText": " 50", "insertText": "Literal", "additionalTextEdits": [ { @@ -27,7 +27,7 @@ expression: completions { "label": "Literal (import typing_extensions)", "kind": 6, - "sortText": " 44", + "sortText": " 51", "insertText": "Literal", "additionalTextEdits": [ { @@ -48,7 +48,7 @@ expression: completions { "label": "LiteralString (import typing)", "kind": 6, - "sortText": " 45", + "sortText": " 52", "insertText": "LiteralString", "additionalTextEdits": [ { @@ -69,7 +69,7 @@ expression: completions { "label": "LiteralString (import typing_extensions)", "kind": 6, - "sortText": " 46", + "sortText": " 53", "insertText": "LiteralString", "additionalTextEdits": [ { diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_same_cell.snap b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_same_cell.snap index 351196f557..ac3881368b 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_same_cell.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_same_cell.snap @@ -6,7 +6,7 @@ expression: completions { "label": "Literal (import typing)", "kind": 6, - "sortText": " 43", + "sortText": " 50", "insertText": "Literal", "additionalTextEdits": [ { @@ -27,7 +27,7 @@ expression: completions { "label": "Literal (import typing_extensions)", "kind": 6, - "sortText": " 44", + "sortText": " 51", "insertText": "Literal", "additionalTextEdits": [ { @@ -48,7 +48,7 @@ expression: completions { "label": "LiteralString (import typing)", "kind": 6, - "sortText": " 45", + "sortText": " 52", "insertText": "LiteralString", "additionalTextEdits": [ { @@ -69,7 +69,7 @@ expression: completions { "label": "LiteralString (import typing_extensions)", "kind": 6, - "sortText": " 46", + "sortText": " 53", "insertText": "LiteralString", "additionalTextEdits": [ { diff --git a/crates/ty_vendored/vendor/typeshed/source_commit.txt b/crates/ty_vendored/vendor/typeshed/source_commit.txt index d0fd6efd8e..7ce1784405 100644 --- a/crates/ty_vendored/vendor/typeshed/source_commit.txt +++ b/crates/ty_vendored/vendor/typeshed/source_commit.txt @@ -1 +1 @@ -bf7214784877c52638844c065360d4814fae4c65 +f8cdc0bd526301e873cd952eb0d457bdf2554e57 diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/_compression.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/_compression.pyi index 12eafa6267..619a67d0c8 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/_compression.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/_compression.pyi @@ -2,7 +2,7 @@ # _compression is replaced by compression._common._streams on Python 3.14+ (PEP-784) -from _typeshed import Incomplete, WriteableBuffer +from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Callable from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase from typing import Any, Protocol, type_check_only @@ -15,6 +15,17 @@ class _Reader(Protocol): def seekable(self) -> bool: ... def seek(self, n: int, /) -> Any: ... +@type_check_only +class _Decompressor(Protocol): + def decompress(self, data: ReadableBuffer, /, max_length: int = ...) -> bytes: ... + @property + def unused_data(self) -> bytes: ... + @property + def eof(self) -> bool: ... + # `zlib._Decompress` does not have next property, but `DecompressReader` calls it: + # @property + # def needs_input(self) -> bool: ... + class BaseStream(BufferedIOBase): """Mode-checking helper functions.""" @@ -24,7 +35,7 @@ class DecompressReader(RawIOBase): def __init__( self, fp: _Reader, - decomp_factory: Callable[..., Incomplete], + decomp_factory: Callable[..., _Decompressor], trailing_error: type[Exception] | tuple[type[Exception], ...] = (), **decomp_args: Any, # These are passed to decomp_factory. ) -> None: ... diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/asyncio/protocols.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/asyncio/protocols.pyi index bd2e9c1118..c6ec1110dd 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/asyncio/protocols.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/asyncio/protocols.pyi @@ -89,7 +89,7 @@ class Protocol(BaseProtocol): """ # Need annotation or mypy will complain about 'Cannot determine type of "__slots__" in base class' - __slots__: tuple[()] = () + __slots__: tuple[str, ...] = () def data_received(self, data: bytes) -> None: """Called when some data is received. @@ -182,7 +182,7 @@ class DatagramProtocol(BaseProtocol): class SubprocessProtocol(BaseProtocol): """Interface for protocol for subprocess calls.""" - __slots__: tuple[()] = () + __slots__: tuple[str, ...] = () def pipe_data_received(self, fd: int, data: bytes) -> None: """Called when the subprocess writes data into stdout/stderr pipe. diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/builtins.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/builtins.pyi index 4859bbe675..9f5df8a708 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/builtins.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/builtins.pyi @@ -54,6 +54,7 @@ from typing import ( # noqa: Y022,UP035 Any, BinaryIO, ClassVar, + Final, Generic, Mapping, MutableMapping, @@ -254,8 +255,9 @@ class type: __bases__: tuple[type, ...] @property def __basicsize__(self) -> int: ... - @property - def __dict__(self) -> types.MappingProxyType[str, Any]: ... # type: ignore[override] + # type.__dict__ is read-only at runtime, but that can't be expressed currently. + # See https://github.com/python/typeshed/issues/11033 for a discussion. + __dict__: Final[types.MappingProxyType[str, Any]] # type: ignore[assignment] @property def __dictoffset__(self) -> int: ... @property @@ -3356,13 +3358,6 @@ class property: def __delete__(self, instance: Any, /) -> None: """Delete an attribute of instance.""" -@final -@type_check_only -class _NotImplementedType(Any): - __call__: None - -NotImplemented: _NotImplementedType - def abs(x: SupportsAbs[_T], /) -> _T: """Return the absolute value of the argument.""" @@ -4494,14 +4489,14 @@ def __build_class__(func: Callable[[], CellType | Any], name: str, /, *bases: An """ if sys.version_info >= (3, 10): - from types import EllipsisType + from types import EllipsisType, NotImplementedType # Backwards compatibility hack for folks who relied on the ellipsis type # existing in typeshed in Python 3.9 and earlier. ellipsis = EllipsisType Ellipsis: EllipsisType - + NotImplemented: NotImplementedType else: # Actually the type of Ellipsis is , but since it's # not exposed anywhere under that name, we make it private here. @@ -4511,6 +4506,12 @@ else: Ellipsis: ellipsis + @final + @type_check_only + class _NotImplementedType(Any): ... + + NotImplemented: _NotImplementedType + @disjoint_base class BaseException: """Common base class for all exceptions""" diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/compression/_common/_streams.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/compression/_common/_streams.pyi index 77866c1a1b..8530440c03 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/compression/_common/_streams.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/compression/_common/_streams.pyi @@ -1,6 +1,6 @@ """Internal classes used by compression modules""" -from _typeshed import Incomplete, WriteableBuffer +from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Callable from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase from typing import Any, Protocol, type_check_only @@ -13,6 +13,17 @@ class _Reader(Protocol): def seekable(self) -> bool: ... def seek(self, n: int, /) -> Any: ... +@type_check_only +class _Decompressor(Protocol): + def decompress(self, data: ReadableBuffer, /, max_length: int = ...) -> bytes: ... + @property + def unused_data(self) -> bytes: ... + @property + def eof(self) -> bool: ... + # `zlib._Decompress` does not have next property, but `DecompressReader` calls it: + # @property + # def needs_input(self) -> bool: ... + class BaseStream(BufferedIOBase): """Mode-checking helper functions.""" @@ -22,7 +33,7 @@ class DecompressReader(RawIOBase): def __init__( self, fp: _Reader, - decomp_factory: Callable[..., Incomplete], # Consider backporting changes to _compression + decomp_factory: Callable[..., _Decompressor], # Consider backporting changes to _compression trailing_error: type[Exception] | tuple[type[Exception], ...] = (), **decomp_args: Any, # These are passed to decomp_factory. ) -> None: ... diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/html/parser.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/html/parser.pyi index 085b51186d..b4cec719a8 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/html/parser.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/html/parser.pyi @@ -32,7 +32,8 @@ class HTMLParser(ParserBase): # Added in Python 3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.6 RCDATA_CONTENT_ELEMENTS: Final[tuple[str, ...]] - def __init__(self, *, convert_charrefs: bool = True) -> None: + # `scripting` parameter added in Python 3.9.25, 3.10.20, 3.11.15, 3.12.13, 3.13.10, 3.14.1 + def __init__(self, *, convert_charrefs: bool = True, scripting: bool = False) -> None: """Initialize and reset this instance. If convert_charrefs is True (the default), all character references diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/http/client.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/http/client.pyi index 4fe786738c..3fbb08e183 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/http/client.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/http/client.pyi @@ -309,6 +309,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): # type: ignore[misc] # incomp def begin(self) -> None: ... class HTTPConnection: + blocksize: int auto_open: int # undocumented debuglevel: int default_port: int # undocumented diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/imaplib.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/imaplib.pyi index dca7377e76..b1cd69b429 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/imaplib.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/imaplib.pyi @@ -85,6 +85,7 @@ class IMAP4: class error(Exception): ... class abort(error): ... class readonly(abort): ... + utf8_enabled: bool mustquote: Pattern[str] debug: int state: str diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/importlib/util.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/importlib/util.pyi index 73acc3a83a..14fc11a281 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/importlib/util.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/importlib/util.pyi @@ -14,7 +14,9 @@ from importlib._bootstrap_external import ( spec_from_file_location as spec_from_file_location, ) from importlib.abc import Loader -from typing_extensions import ParamSpec, deprecated +from types import TracebackType +from typing import Literal +from typing_extensions import ParamSpec, Self, deprecated _P = ParamSpec("_P") @@ -99,6 +101,49 @@ class LazyLoader(Loader): def source_hash(source_bytes: ReadableBuffer) -> bytes: """Return the hash of *source_bytes* as used in hash-based pyc files.""" +if sys.version_info >= (3, 12): + class _incompatible_extension_module_restrictions: + """A context manager that can temporarily skip the compatibility check. + + NOTE: This function is meant to accommodate an unusual case; one + which is likely to eventually go away. There's is a pretty good + chance this is not what you were looking for. + + WARNING: Using this function to disable the check can lead to + unexpected behavior and even crashes. It should only be used during + extension module development. + + If "disable_check" is True then the compatibility check will not + happen while the context manager is active. Otherwise the check + *will* happen. + + Normally, extensions that do not support multiple interpreters + may not be imported in a subinterpreter. That implies modules + that do not implement multi-phase init or that explicitly of out. + + Likewise for modules import in a subinterpreter with its own GIL + when the extension does not support a per-interpreter GIL. This + implies the module does not have a Py_mod_multiple_interpreters slot + set to Py_MOD_PER_INTERPRETER_GIL_SUPPORTED. + + In both cases, this context manager may be used to temporarily + disable the check for compatible extension modules. + + You can get the same effect as this function by implementing the + basic interface of multi-phase init (PEP 489) and lying about + support for multiple interpreters (or per-interpreter GIL). + """ + + def __init__(self, *, disable_check: bool) -> None: ... + disable_check: bool + old: Literal[-1, 0, 1] # exists only while entered + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... + @property + def override(self) -> Literal[-1, 1]: ... # undocumented + if sys.version_info >= (3, 14): __all__ = [ "LazyLoader", diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/locale.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/locale.pyi index ed836048f4..51e74c47d6 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/locale.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/locale.pyi @@ -251,6 +251,10 @@ def currency(val: float | Decimal, symbol: bool = True, grouping: bool = False, def delocalize(string: _str) -> _str: """Parses a string as a normalized number according to the locale settings.""" +if sys.version_info >= (3, 10): + def localize(string: _str, grouping: bool = False, monetary: bool = False) -> _str: + """Parses a string as locale number according to the locale settings.""" + def atof(string: _str, func: Callable[[_str], float] = ...) -> float: """Parses a string as a float according to the locale settings.""" diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/os/__init__.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/os/__init__.pyi index 1ea3e4ea80..c1494f446a 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/os/__init__.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/os/__init__.pyi @@ -64,10 +64,22 @@ from typing import ( runtime_checkable, type_check_only, ) -from typing_extensions import Self, TypeAlias, Unpack, deprecated +from typing_extensions import LiteralString, Self, TypeAlias, Unpack, deprecated from . import path as _path +# Re-export common definitions from os.path to reduce duplication +from .path import ( + altsep as altsep, + curdir as curdir, + defpath as defpath, + devnull as devnull, + extsep as extsep, + pardir as pardir, + pathsep as pathsep, + sep as sep, +) + __all__ = [ "F_OK", "O_APPEND", @@ -697,19 +709,8 @@ if sys.platform != "win32": ST_NOSUID: Final[int] ST_RDONLY: Final[int] -curdir: str -pardir: str -sep: str -if sys.platform == "win32": - altsep: str -else: - altsep: str | None -extsep: str -pathsep: str -defpath: str linesep: Literal["\n", "\r\n"] -devnull: str -name: str +name: LiteralString F_OK: Final = 0 R_OK: Final = 4 diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/parser.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/parser.pyi index 0c616fefc9..0ecdba2d6d 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/parser.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/parser.pyi @@ -17,10 +17,10 @@ def sequence2st(sequence: Sequence[Any]) -> STType: def tuple2st(sequence: Sequence[Any]) -> STType: """Creates an ST object from a tree representation.""" -def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> list[Any]: +def st2list(st: STType, line_info: bool = False, col_info: bool = False) -> list[Any]: """Creates a list-tree representation of an ST.""" -def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: +def st2tuple(st: STType, line_info: bool = False, col_info: bool = False) -> tuple[Any, ...]: """Creates a tuple-tree representation of an ST.""" def compilest(st: STType, filename: StrOrBytesPath = ...) -> CodeType: @@ -48,8 +48,8 @@ class STType: def issuite(self) -> bool: """Determines if this ST object was created from a suite.""" - def tolist(self, line_info: bool = ..., col_info: bool = ...) -> list[Any]: + def tolist(self, line_info: bool = False, col_info: bool = False) -> list[Any]: """Creates a list-tree representation of this ST.""" - def totuple(self, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: + def totuple(self, line_info: bool = False, col_info: bool = False) -> tuple[Any, ...]: """Creates a tuple-tree representation of this ST.""" diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/select.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/select.pyi index 93d3b5a72f..bd35cac3ff 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/select.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/select.pyi @@ -8,8 +8,8 @@ import sys from _typeshed import FileDescriptorLike from collections.abc import Iterable from types import TracebackType -from typing import Any, ClassVar, Final, final -from typing_extensions import Self +from typing import Any, ClassVar, Final, TypeVar, final +from typing_extensions import Never, Self if sys.platform != "win32": PIPE_BUF: Final[int] @@ -43,9 +43,13 @@ if sys.platform != "win32": def unregister(self, fd: FileDescriptorLike, /) -> None: ... def poll(self, timeout: float | None = None, /) -> list[tuple[int, int]]: ... +_R = TypeVar("_R", default=Never) +_W = TypeVar("_W", default=Never) +_X = TypeVar("_X", default=Never) + def select( - rlist: Iterable[Any], wlist: Iterable[Any], xlist: Iterable[Any], timeout: float | None = None, / -) -> tuple[list[Any], list[Any], list[Any]]: + rlist: Iterable[_R], wlist: Iterable[_W], xlist: Iterable[_X], timeout: float | None = None, / +) -> tuple[list[_R], list[_W], list[_X]]: """Wait until one or more file descriptors are ready for some kind of I/O. The first three arguments are iterables of file descriptors to be waited for: diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/ssl.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/ssl.pyi index b4540c8ca8..05ccdcd9e2 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/ssl.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/ssl.pyi @@ -123,6 +123,9 @@ from typing_extensions import Never, Self, TypeAlias, deprecated if sys.version_info >= (3, 13): from _ssl import HAS_PSK as HAS_PSK +if sys.version_info >= (3, 14): + from _ssl import HAS_PHA as HAS_PHA + if sys.version_info < (3, 12): from _ssl import RAND_pseudo_bytes as RAND_pseudo_bytes diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/stat.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/stat.pyi index cee0bea41f..c8b4dbff33 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/stat.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/stat.pyi @@ -4,9 +4,116 @@ Suggested usage: from stat import * """ import sys -from _stat import * +from _stat import ( + S_ENFMT as S_ENFMT, + S_IEXEC as S_IEXEC, + S_IFBLK as S_IFBLK, + S_IFCHR as S_IFCHR, + S_IFDIR as S_IFDIR, + S_IFDOOR as S_IFDOOR, + S_IFIFO as S_IFIFO, + S_IFLNK as S_IFLNK, + S_IFMT as S_IFMT, + S_IFPORT as S_IFPORT, + S_IFREG as S_IFREG, + S_IFSOCK as S_IFSOCK, + S_IFWHT as S_IFWHT, + S_IMODE as S_IMODE, + S_IREAD as S_IREAD, + S_IRGRP as S_IRGRP, + S_IROTH as S_IROTH, + S_IRUSR as S_IRUSR, + S_IRWXG as S_IRWXG, + S_IRWXO as S_IRWXO, + S_IRWXU as S_IRWXU, + S_ISBLK as S_ISBLK, + S_ISCHR as S_ISCHR, + S_ISDIR as S_ISDIR, + S_ISDOOR as S_ISDOOR, + S_ISFIFO as S_ISFIFO, + S_ISGID as S_ISGID, + S_ISLNK as S_ISLNK, + S_ISPORT as S_ISPORT, + S_ISREG as S_ISREG, + S_ISSOCK as S_ISSOCK, + S_ISUID as S_ISUID, + S_ISVTX as S_ISVTX, + S_ISWHT as S_ISWHT, + S_IWGRP as S_IWGRP, + S_IWOTH as S_IWOTH, + S_IWRITE as S_IWRITE, + S_IWUSR as S_IWUSR, + S_IXGRP as S_IXGRP, + S_IXOTH as S_IXOTH, + S_IXUSR as S_IXUSR, + SF_APPEND as SF_APPEND, + SF_ARCHIVED as SF_ARCHIVED, + SF_IMMUTABLE as SF_IMMUTABLE, + SF_NOUNLINK as SF_NOUNLINK, + SF_SNAPSHOT as SF_SNAPSHOT, + ST_ATIME as ST_ATIME, + ST_CTIME as ST_CTIME, + ST_DEV as ST_DEV, + ST_GID as ST_GID, + ST_INO as ST_INO, + ST_MODE as ST_MODE, + ST_MTIME as ST_MTIME, + ST_NLINK as ST_NLINK, + ST_SIZE as ST_SIZE, + ST_UID as ST_UID, + UF_APPEND as UF_APPEND, + UF_COMPRESSED as UF_COMPRESSED, + UF_HIDDEN as UF_HIDDEN, + UF_IMMUTABLE as UF_IMMUTABLE, + UF_NODUMP as UF_NODUMP, + UF_NOUNLINK as UF_NOUNLINK, + UF_OPAQUE as UF_OPAQUE, + filemode as filemode, +) from typing import Final +if sys.platform == "win32": + from _stat import ( + IO_REPARSE_TAG_APPEXECLINK as IO_REPARSE_TAG_APPEXECLINK, + IO_REPARSE_TAG_MOUNT_POINT as IO_REPARSE_TAG_MOUNT_POINT, + IO_REPARSE_TAG_SYMLINK as IO_REPARSE_TAG_SYMLINK, + ) + +if sys.version_info >= (3, 13): + from _stat import ( + SF_DATALESS as SF_DATALESS, + SF_FIRMLINK as SF_FIRMLINK, + SF_SETTABLE as SF_SETTABLE, + UF_DATAVAULT as UF_DATAVAULT, + UF_SETTABLE as UF_SETTABLE, + UF_TRACKED as UF_TRACKED, + ) + + if sys.platform == "darwin": + from _stat import SF_SUPPORTED as SF_SUPPORTED, SF_SYNTHETIC as SF_SYNTHETIC + +# _stat.c defines FILE_ATTRIBUTE_* constants conditionally, +# making them available only at runtime on Windows. +# stat.py unconditionally redefines the same FILE_ATTRIBUTE_* constants +# on all platforms. +FILE_ATTRIBUTE_ARCHIVE: Final = 32 +FILE_ATTRIBUTE_COMPRESSED: Final = 2048 +FILE_ATTRIBUTE_DEVICE: Final = 64 +FILE_ATTRIBUTE_DIRECTORY: Final = 16 +FILE_ATTRIBUTE_ENCRYPTED: Final = 16384 +FILE_ATTRIBUTE_HIDDEN: Final = 2 +FILE_ATTRIBUTE_INTEGRITY_STREAM: Final = 32768 +FILE_ATTRIBUTE_NORMAL: Final = 128 +FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: Final = 8192 +FILE_ATTRIBUTE_NO_SCRUB_DATA: Final = 131072 +FILE_ATTRIBUTE_OFFLINE: Final = 4096 +FILE_ATTRIBUTE_READONLY: Final = 1 +FILE_ATTRIBUTE_REPARSE_POINT: Final = 1024 +FILE_ATTRIBUTE_SPARSE_FILE: Final = 512 +FILE_ATTRIBUTE_SYSTEM: Final = 4 +FILE_ATTRIBUTE_TEMPORARY: Final = 256 +FILE_ATTRIBUTE_VIRTUAL: Final = 65536 + if sys.version_info >= (3, 13): # https://github.com/python/cpython/issues/114081#issuecomment-2119017790 SF_RESTRICTED: Final = 0x00080000 diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/sys/__init__.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/sys/__init__.pyi index 0ecc8e2693..eef3dd37b5 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/sys/__init__.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/sys/__init__.pyi @@ -763,6 +763,8 @@ def intern(string: str, /) -> str: the previously interned string object with the same value. """ +__interactivehook__: Callable[[], object] + if sys.version_info >= (3, 13): def _is_gil_enabled() -> bool: """Return True if the GIL is currently enabled and False otherwise.""" diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/sys/_monitoring.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/sys/_monitoring.pyi index 5d231c7a93..db799e6f32 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/sys/_monitoring.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/sys/_monitoring.pyi @@ -17,6 +17,10 @@ PROFILER_ID: Final = 2 OPTIMIZER_ID: Final = 5 def use_tool_id(tool_id: int, name: str, /) -> None: ... + +if sys.version_info >= (3, 14): + def clear_tool_id(tool_id: int, /) -> None: ... + def free_tool_id(tool_id: int, /) -> None: ... def get_tool(tool_id: int, /) -> str | None: ... @@ -43,10 +47,10 @@ class _events: STOP_ITERATION: Final[int] if sys.version_info >= (3, 14): BRANCH_LEFT: Final[int] - BRANCH_TAKEN: Final[int] + BRANCH_RIGHT: Final[int] @property - @deprecated("Deprecated since Python 3.14. Use `BRANCH_LEFT` or `BRANCH_TAKEN` instead.") + @deprecated("Deprecated since Python 3.14. Use `BRANCH_LEFT` or `BRANCH_RIGHT` instead.") def BRANCH(self) -> int: ... else: diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/threading.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/threading.pyi index 95244ee608..4a52cc0561 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/threading.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/threading.pyi @@ -2,7 +2,7 @@ import _thread import sys -from _thread import _excepthook, _ExceptHookArgs, get_native_id as get_native_id +from _thread import _ExceptHookArgs, get_native_id as get_native_id from _typeshed import ProfileFunction, TraceFunction from collections.abc import Callable, Iterable, Mapping from contextvars import ContextVar @@ -647,7 +647,9 @@ class Event: """ -excepthook = _excepthook +excepthook: Callable[[_ExceptHookArgs], object] +if sys.version_info >= (3, 10): + __excepthook__: Callable[[_ExceptHookArgs], object] ExceptHookArgs = _ExceptHookArgs class Timer(Thread): diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/types.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/types.pyi index 9c428718da..61cdd0efb1 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/types.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/types.pyi @@ -957,9 +957,10 @@ if sys.version_info >= (3, 10): class EllipsisType: """The type of the Ellipsis singleton.""" - from builtins import _NotImplementedType + @final + class NotImplementedType(Any): + """The type of the NotImplemented singleton.""" - NotImplementedType = _NotImplementedType @final class UnionType: """Represent a union type diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/typing.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/typing.pyi index b5533714ac..8daf975d2b 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/typing.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/typing.pyi @@ -328,10 +328,6 @@ class TypeVar: @property def evaluate_default(self) -> EvaluateFunc | None: ... -# Used for an undocumented mypy feature. Does not exist at runtime. -# Obsolete, use _typeshed._type_checker_internals.promote instead. -_promote = object() - # N.B. Keep this definition in sync with typing_extensions._SpecialForm @final class _SpecialForm(_Final): diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/unittest/util.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/unittest/util.pyi index 0bed55dbcc..7fd80f7c7f 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/unittest/util.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/unittest/util.pyi @@ -1,11 +1,28 @@ """Various utility functions.""" from collections.abc import MutableSequence, Sequence -from typing import Any, Final, TypeVar +from typing import Any, Final, Literal, Protocol, TypeVar, type_check_only from typing_extensions import TypeAlias +@type_check_only +class _SupportsDunderLT(Protocol): + def __lt__(self, other: Any, /) -> bool: ... + +@type_check_only +class _SupportsDunderGT(Protocol): + def __gt__(self, other: Any, /) -> bool: ... + +@type_check_only +class _SupportsDunderLE(Protocol): + def __le__(self, other: Any, /) -> bool: ... + +@type_check_only +class _SupportsDunderGE(Protocol): + def __ge__(self, other: Any, /) -> bool: ... + _T = TypeVar("_T") _Mismatch: TypeAlias = tuple[_T, _T, int] +_SupportsComparison: TypeAlias = _SupportsDunderLE | _SupportsDunderGE | _SupportsDunderGT | _SupportsDunderLT _MAX_LENGTH: Final = 80 _PLACEHOLDER_LEN: Final = 12 @@ -35,7 +52,7 @@ def unorderable_list_difference(expected: MutableSequence[_T], actual: MutableSe has O(n*n) performance. """ -def three_way_cmp(x: Any, y: Any) -> int: +def three_way_cmp(x: _SupportsComparison, y: _SupportsComparison) -> Literal[-1, 0, 1]: """Return -1 if x < y, 0 if x == y and 1 if x > y""" def _count_diff_all_purpose(actual: Sequence[_T], expected: Sequence[_T]) -> list[_Mismatch[_T]]: diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/uuid.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/uuid.pyi index 86a27772a7..7bf495692a 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/uuid.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/uuid.pyi @@ -58,8 +58,9 @@ Typical usage: import builtins import sys +from _typeshed import Unused from enum import Enum -from typing import Final +from typing import Final, NoReturn from typing_extensions import LiteralString, TypeAlias _FieldsType: TypeAlias = tuple[int, int, int, int, int, int] @@ -134,6 +135,9 @@ class UUID: """ __slots__ = ("int", "is_safe", "__weakref__") + is_safe: Final[SafeUUID] + int: Final[builtins.int] + def __init__( self, hex: str | None = None, @@ -174,8 +178,6 @@ class UUID: for multiprocessing applications, via uuid_generate_time_safe(3). """ - @property - def is_safe(self) -> SafeUUID: ... @property def bytes(self) -> builtins.bytes: ... @property @@ -191,8 +193,6 @@ class UUID: @property def hex(self) -> str: ... @property - def int(self) -> builtins.int: ... - @property def node(self) -> builtins.int: ... @property def time(self) -> builtins.int: ... @@ -215,6 +215,7 @@ class UUID: def __gt__(self, other: UUID) -> bool: ... def __ge__(self, other: UUID) -> bool: ... def __hash__(self) -> builtins.int: ... + def __setattr__(self, name: Unused, value: Unused) -> NoReturn: ... def getnode() -> int: """Get the hardware address as a 48-bit positive integer. diff --git a/crates/ty_vendored/vendor/typeshed/stdlib/winreg.pyi b/crates/ty_vendored/vendor/typeshed/stdlib/winreg.pyi index ae3009add5..c114161fe4 100644 --- a/crates/ty_vendored/vendor/typeshed/stdlib/winreg.pyi +++ b/crates/ty_vendored/vendor/typeshed/stdlib/winreg.pyi @@ -238,7 +238,7 @@ if sys.platform == "win32": tree. """ - def OpenKey(key: _KeyType, sub_key: str, reserved: int = 0, access: int = 131097) -> HKEYType: + def OpenKey(key: _KeyType, sub_key: str | None, reserved: int = 0, access: int = 131097) -> HKEYType: """Opens the specified key. key @@ -255,7 +255,7 @@ if sys.platform == "win32": If the function fails, an OSError exception is raised. """ - def OpenKeyEx(key: _KeyType, sub_key: str, reserved: int = 0, access: int = 131097) -> HKEYType: + def OpenKeyEx(key: _KeyType, sub_key: str | None, reserved: int = 0, access: int = 131097) -> HKEYType: """Opens the specified key. key @@ -336,7 +336,7 @@ if sys.platform == "win32": to the API. """ - def SetValue(key: _KeyType, sub_key: str, type: int, value: str, /) -> None: + def SetValue(key: _KeyType, sub_key: str | None, type: int, value: str, /) -> None: """Associates a value with a specified key. key