File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
crates/red_knot_python_semantic Expand file tree Collapse file tree 2 files changed +19
-0
lines changed 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> {
2678
2678
) ) )
2679
2679
}
2680
2680
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
+
2681
2688
instance_ty @ Type :: Instance ( _) => {
2682
2689
instance_ty
2683
2690
. try_call_dunder ( db, "__call__" , arguments)
You can’t perform that action at this time.
0 commit comments