[ty] Sync vendored typeshed stubs (#21466)

Co-authored-by: typeshedbot <>
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
github-actions[bot]
2025-11-15 17:12:32 +00:00
committed by GitHub
parent 29acc1e860
commit efa2b5167f
38 changed files with 432 additions and 157 deletions

View File

@@ -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],

View File

@@ -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))
}