File tree Expand file tree Collapse file tree
crates/red_knot_python_semantic/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2046,13 +2046,17 @@ impl<'db> Type<'db> {
20462046 ) ;
20472047
20482048 let custom_getattr_result = || {
2049- // Typeshed has a fake `__getattr__` on `types.ModuleType` to help out with dynamic imports.
2050- // We explicitly hide it here to prevent arbitrary attributes from being available on modules.
2051- if self
2052- . into_instance ( )
2053- . is_some_and ( |instance| instance. class . is_known ( db, KnownClass :: ModuleType ) )
2054- {
2055- return Symbol :: Unbound . into ( ) ;
2049+ if let Some ( instance) = self . into_instance ( ) {
2050+ match instance. class . known ( db) {
2051+ // Typeshed has a fake `__getattr__` on `types.ModuleType` to help out with dynamic imports.
2052+ // We explicitly hide it here to prevent arbitrary attributes from being available on modules.
2053+ Some ( KnownClass :: ModuleType ) => return Symbol :: Unbound . into ( ) ,
2054+
2055+ // TODO: For now we are treating a TypeVar as Any.
2056+ Some ( KnownClass :: TypeVar ) => return Symbol :: bound ( Type :: any ( ) ) . into ( ) ,
2057+
2058+ _ => { }
2059+ }
20562060 }
20572061
20582062 self . try_call_dunder (
You can’t perform that action at this time.
0 commit comments