File tree Expand file tree Collapse file tree
crates/red_knot_python_semantic Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Call ` type[...] `
2+
3+ ## Dynamic base
4+
5+ ``` py
6+ from typing import Any
7+ from knot_extensions import Unknown
8+
9+ def _ (subclass_of_any : type[Any], subclass_of_unknown : type[Unknown]):
10+ reveal_type(subclass_of_any()) # revealed: Any
11+ reveal_type(subclass_of_unknown()) # revealed: Unknown
12+ ```
Original file line number Diff line number Diff line change @@ -2678,6 +2678,13 @@ impl<'db> Type<'db> {
26782678 ) ) )
26792679 }
26802680
2681+ Type :: SubclassOf ( subclass_of_type) => match subclass_of_type. subclass_of ( ) {
2682+ ClassBase :: Dynamic ( dynamic_type) => Ok ( CallOutcome :: Single (
2683+ CallBinding :: from_return_type ( Type :: Dynamic ( dynamic_type) ) ,
2684+ ) ) ,
2685+ ClassBase :: Class ( class) => Type :: class_literal ( class) . try_call ( db, arguments) ,
2686+ } ,
2687+
26812688 instance_ty @ Type :: Instance ( _) => {
26822689 instance_ty
26832690 . try_call_dunder ( db, "__call__" , arguments)
You can’t perform that action at this time.
0 commit comments