Update tests
This commit is contained in:
@@ -20,7 +20,7 @@ x: IntOrStr = 1
|
||||
reveal_type(x) # revealed: Literal[1]
|
||||
|
||||
def f() -> None:
|
||||
reveal_type(x) # revealed: int | str
|
||||
reveal_type(x) # revealed: IntOrStr
|
||||
```
|
||||
|
||||
## `__value__` attribute
|
||||
@@ -49,7 +49,7 @@ type IntOrStrOrBytes = IntOrStr | bytes
|
||||
x: IntOrStrOrBytes = 1
|
||||
|
||||
def f() -> None:
|
||||
reveal_type(x) # revealed: int | str | bytes
|
||||
reveal_type(x) # revealed: IntOrStrOrBytes
|
||||
```
|
||||
|
||||
## Aliased type aliases
|
||||
@@ -109,7 +109,7 @@ reveal_type(IntOrStr) # revealed: typing.TypeAliasType
|
||||
reveal_type(IntOrStr.__name__) # revealed: Literal["IntOrStr"]
|
||||
|
||||
def f(x: IntOrStr) -> None:
|
||||
reveal_type(x) # revealed: int | str
|
||||
reveal_type(x) # revealed: IntOrStr
|
||||
```
|
||||
|
||||
### Generic example
|
||||
|
||||
@@ -196,21 +196,21 @@ def _(
|
||||
bytes_or_falsy: bytes | AlwaysFalsy,
|
||||
falsy_or_bytes: AlwaysFalsy | bytes,
|
||||
):
|
||||
reveal_type(strings_or_truthy) # revealed: Literal[""] | AlwaysTruthy
|
||||
reveal_type(truthy_or_strings) # revealed: AlwaysTruthy | Literal[""]
|
||||
reveal_type(strings_or_truthy) # revealed: strings | AlwaysTruthy
|
||||
reveal_type(truthy_or_strings) # revealed: AlwaysTruthy | strings
|
||||
|
||||
reveal_type(strings_or_falsy) # revealed: Literal["foo"] | AlwaysFalsy
|
||||
reveal_type(falsy_or_strings) # revealed: AlwaysFalsy | Literal["foo"]
|
||||
reveal_type(strings_or_falsy) # revealed: strings | AlwaysFalsy
|
||||
reveal_type(falsy_or_strings) # revealed: AlwaysFalsy | strings
|
||||
|
||||
reveal_type(ints_or_truthy) # revealed: Literal[0] | AlwaysTruthy
|
||||
reveal_type(truthy_or_ints) # revealed: AlwaysTruthy | Literal[0]
|
||||
reveal_type(ints_or_truthy) # revealed: ints | AlwaysTruthy
|
||||
reveal_type(truthy_or_ints) # revealed: AlwaysTruthy | ints
|
||||
|
||||
reveal_type(ints_or_falsy) # revealed: Literal[1] | AlwaysFalsy
|
||||
reveal_type(falsy_or_ints) # revealed: AlwaysFalsy | Literal[1]
|
||||
reveal_type(ints_or_falsy) # revealed: ints | AlwaysFalsy
|
||||
reveal_type(falsy_or_ints) # revealed: AlwaysFalsy | ints
|
||||
|
||||
reveal_type(bytes_or_truthy) # revealed: Literal[b""] | AlwaysTruthy
|
||||
reveal_type(truthy_or_bytes) # revealed: AlwaysTruthy | Literal[b""]
|
||||
reveal_type(bytes_or_truthy) # revealed: bytes | AlwaysTruthy
|
||||
reveal_type(truthy_or_bytes) # revealed: AlwaysTruthy | bytes
|
||||
|
||||
reveal_type(bytes_or_falsy) # revealed: Literal[b"foo"] | AlwaysFalsy
|
||||
reveal_type(falsy_or_bytes) # revealed: AlwaysFalsy | Literal[b"foo"]
|
||||
reveal_type(bytes_or_falsy) # revealed: bytes | AlwaysFalsy
|
||||
reveal_type(falsy_or_bytes) # revealed: AlwaysFalsy | bytes
|
||||
```
|
||||
|
||||
@@ -260,6 +260,7 @@ fn member_lookup_cycle_initial<'db>(
|
||||
Symbol::bound(Type::Never).into()
|
||||
}
|
||||
|
||||
#[expect(clippy::trivially_copy_pass_by_ref)]
|
||||
fn is_fully_static_cycle_recover<'db>(
|
||||
_db: &'db dyn Db,
|
||||
_value: &bool,
|
||||
@@ -1006,7 +1007,7 @@ impl<'db> Type<'db> {
|
||||
#[must_use]
|
||||
pub fn normalized(self, db: &'db dyn Db) -> Self {
|
||||
match self {
|
||||
Type::TypeAliasRef(alias) => self,
|
||||
Type::TypeAliasRef(_) => self,
|
||||
Type::Union(union) => Type::Union(union.normalized(db)),
|
||||
Type::Intersection(intersection) => Type::Intersection(intersection.normalized(db)),
|
||||
Type::Tuple(tuple) => Type::Tuple(tuple.normalized(db)),
|
||||
@@ -2261,11 +2262,11 @@ impl<'db> Type<'db> {
|
||||
}
|
||||
|
||||
/// Returns true if the type does not contain any gradual forms (as a sub-part).
|
||||
|
||||
pub(crate) fn is_fully_static(self, db: &'db dyn Db) -> bool {
|
||||
self.is_fully_static_impl(db, ())
|
||||
}
|
||||
|
||||
#[allow(clippy::used_underscore_binding)]
|
||||
#[salsa::tracked(cycle_fn=is_fully_static_cycle_recover, cycle_initial=is_fully_static_cycle_initial)]
|
||||
pub(crate) fn is_fully_static_impl(self, db: &'db dyn Db, _dummy: ()) -> bool {
|
||||
match self {
|
||||
@@ -5341,7 +5342,7 @@ impl<'db> Type<'db> {
|
||||
type_mapping: &TypeMapping<'a, 'db>,
|
||||
) -> Type<'db> {
|
||||
match self {
|
||||
Type::TypeAliasRef(alias) => todo_type!("type alias"),
|
||||
Type::TypeAliasRef(_) => self,
|
||||
Type::TypeVar(typevar) => match type_mapping {
|
||||
TypeMapping::Specialization(specialization) => {
|
||||
specialization.get(db, typevar).unwrap_or(self)
|
||||
|
||||
Reference in New Issue
Block a user