mirror of https://github.com/astral-sh/ruff
[ty] Sync vendored typeshed stubs (#21466)
Co-authored-by: typeshedbot <> Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
parent
29acc1e860
commit
efa2b5167f
|
|
@ -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`.
|
||||
#
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
|
@ -1206,7 +1206,6 @@ type<CURSOR>
|
|||
@r"
|
||||
TypeError :: <class 'TypeError'>
|
||||
type :: <class 'type'>
|
||||
_NotImplementedType :: <class '_NotImplementedType'>
|
||||
",
|
||||
);
|
||||
}
|
||||
|
|
@ -2092,7 +2091,7 @@ C.<CURSOR>
|
|||
__call__ :: bound method <class 'C'>.__call__(...) -> Any
|
||||
__class__ :: <class 'Meta'>
|
||||
__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.<CURSOR>
|
|||
__call__ :: bound method <class 'Quux'>.__call__(...) -> Any
|
||||
__class__ :: <class 'type'>
|
||||
__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.<CURSOR>
|
|||
__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
|
||||
|
|
|
|||
|
|
@ -1605,13 +1605,13 @@ a: float<CURSOR> = 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<CURSOR> = 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<CURSOR> = 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<CURSOR> = 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<CURSOR> = 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
|
||||
|
|
|
|||
|
|
@ -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<CURSOR>)
|
|||
|
||||
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<CURSOR>)
|
|||
|
||||
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<CURSOR>)
|
|||
|
||||
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<CURSOR>)
|
|||
|
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -717,3 +717,17 @@ class F[T](F(), F): ... # error: [cyclic-class-definition]
|
|||
reveal_type(F.__class__) # revealed: type[Unknown]
|
||||
reveal_mro(F) # revealed: (<class 'F[Unknown]'>, Unknown, <class 'object'>)
|
||||
```
|
||||
|
||||
## `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: (<class 'NotImplementedType'>, <class 'object'>)
|
||||
reveal_mro(type(NotImplemented)) # revealed: (<class 'NotImplementedType'>, <class 'object'>)
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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<Specialization<'db>>,
|
||||
) -> Result<Self, MroError<'db>> {
|
||||
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))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
bf7214784877c52638844c065360d4814fae4c65
|
||||
f8cdc0bd526301e873cd952eb0d457bdf2554e57
|
||||
|
|
|
|||
|
|
@ -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: ...
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <type 'ellipsis'>, 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"""
|
||||
|
|
|
|||
|
|
@ -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: ...
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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]]:
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue