[ty] Sync vendored typeshed stubs (#20876)

Close and reopen this PR to trigger CI

---------

Co-authored-by: typeshedbot <>
Co-authored-by: David Peter <mail@david-peter.de>
This commit is contained in:
github-actions[bot] 2025-10-15 11:13:32 +02:00 committed by GitHub
parent 651f7963a7
commit cafb96aa7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 487 additions and 288 deletions

View file

@ -7957,6 +7957,21 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
)))
}
// Special-case `X | Y` with `X` and `Y` instances of `type` to produce a `types.UnionType` instance, in order to
// overwrite the typeshed return type for `type.__or__`, which would result in `types.UnionType | X`. We currently
// do this to avoid false positives when a legacy type alias like `IntOrStr = int | str` is later used in a type
// expression, because `types.UnionType` will result in a `@Todo` type, while `types.UnionType | <class 'int'>` does
// not.
//
// TODO: Remove this special case once we add support for legacy type aliases.
(
Type::ClassLiteral(..) | Type::SubclassOf(..) | Type::GenericAlias(..),
Type::ClassLiteral(..) | Type::SubclassOf(..) | Type::GenericAlias(..),
ast::Operator::BitOr,
) if Program::get(self.db()).python_version(self.db()) >= PythonVersion::PY310 => {
Some(KnownClass::UnionType.to_instance(self.db()))
}
// We've handled all of the special cases that we support for literals, so we need to
// fall back on looking for dunder methods on one of the operand types.
(