mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
[red-knot] Distribute intersections on negation (#13962)
## Summary This does two things: - distribute negated intersections when building up intersections (i.e. going from `A & ~(B & C)` to `(A & ~B) | (A & ~C)`) (fixing #13931) ## Test Plan `cargo test`
This commit is contained in:
parent
b6847b371e
commit
2fe203292a
3 changed files with 103 additions and 5 deletions
|
@ -10,6 +10,9 @@ use crate::Db;
|
|||
enum CoreStdlibModule {
|
||||
Builtins,
|
||||
Types,
|
||||
// the Typing enum is currently only used in tests
|
||||
#[allow(dead_code)]
|
||||
Typing,
|
||||
Typeshed,
|
||||
TypingExtensions,
|
||||
}
|
||||
|
@ -19,6 +22,7 @@ impl CoreStdlibModule {
|
|||
let module_name = match self {
|
||||
Self::Builtins => "builtins",
|
||||
Self::Types => "types",
|
||||
Self::Typing => "typing",
|
||||
Self::Typeshed => "_typeshed",
|
||||
Self::TypingExtensions => "typing_extensions",
|
||||
};
|
||||
|
@ -63,6 +67,14 @@ pub(crate) fn types_symbol_ty<'db>(db: &'db dyn Db, symbol: &str) -> Type<'db> {
|
|||
core_module_symbol_ty(db, CoreStdlibModule::Types, symbol)
|
||||
}
|
||||
|
||||
/// Lookup the type of `symbol` in the `typing` module namespace.
|
||||
///
|
||||
/// Returns `Unbound` if the `typing` module isn't available for some reason.
|
||||
#[inline]
|
||||
#[allow(dead_code)] // currently only used in tests
|
||||
pub(crate) fn typing_symbol_ty<'db>(db: &'db dyn Db, symbol: &str) -> Type<'db> {
|
||||
core_module_symbol_ty(db, CoreStdlibModule::Typing, symbol)
|
||||
}
|
||||
/// Lookup the type of `symbol` in the `_typeshed` module namespace.
|
||||
///
|
||||
/// Returns `Unbound` if the `_typeshed` module isn't available for some reason.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue