Skip to content

Commit

Permalink
describe the test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Jan 17, 2025
1 parent 832ae84 commit 0ca4bff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ def _(x: type, y: type[int]):

### Disjoint `type[]` types are narrowed to `Never`

Here, `type[UsesMeta1]` and `type[UsesMeta2]` are disjoint because a common subclass of `UsesMeta1`
and `UsesMeta2` could only exist if a common subclass of their metaclasses could exist. This is
known to be impossible due to the fact that `Meta1` is marked as `@final`.

```py
from typing import final

Expand Down
2 changes: 1 addition & 1 deletion crates/red_knot_python_semantic/src/types/subclass_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl<'db> SubclassOfType<'db> {
}

/// A class `T` is an instance of its metaclass `U`,
/// so the type `type[T]` is a strict subtype of the instance type `U`.
/// so the type `type[T]` is a subtype of the instance type `U`.
pub(crate) fn as_instance_type_of_metaclass(&self, db: &'db dyn Db) -> Type<'db> {
match self.subclass_of {
ClassBase::Dynamic(_) => KnownClass::Type.to_instance(db),
Expand Down

0 comments on commit 0ca4bff

Please sign in to comment.