@@ -3138,7 +3138,7 @@ def check_assignment(
31383138                        else :
31393139                            self .check_getattr_method (signature , lvalue , name )
31403140
3141-                 if  name  ==  "__slots__" :
3141+                 if  name  ==  "__slots__"   and   self . scope . active_class ()  is   not   None :
31423142                    typ  =  lvalue_type  or  self .expr_checker .accept (rvalue )
31433143                    self .check_slots_definition (typ , lvalue )
31443144                if  name  ==  "__match_args__"  and  inferred  is  not None :
@@ -3317,6 +3317,12 @@ def get_variable_type_context(self, inferred: Var, rvalue: Expression) -> Type |
33173317                    type_contexts .append (base_type )
33183318        # Use most derived supertype as type context if available. 
33193319        if  not  type_contexts :
3320+             if  inferred .name  ==  "__slots__"  and  self .scope .active_class () is  not None :
3321+                 str_type  =  self .named_type ("builtins.str" )
3322+                 return  self .named_generic_type ("typing.Iterable" , [str_type ])
3323+             if  inferred .name  ==  "__all__"  and  self .scope .is_top_level ():
3324+                 str_type  =  self .named_type ("builtins.str" )
3325+                 return  self .named_generic_type ("typing.Sequence" , [str_type ])
33203326            return  None 
33213327        candidate  =  type_contexts [0 ]
33223328        for  other  in  type_contexts :
@@ -7273,7 +7279,7 @@ def named_type(self, name: str) -> Instance:
72737279        if  isinstance (node , TypeAlias ):
72747280            assert  isinstance (node .target , Instance )  # type: ignore[misc] 
72757281            node  =  node .target .type 
7276-         assert  isinstance (node , TypeInfo )
7282+         assert  isinstance (node , TypeInfo ),  node 
72777283        any_type  =  AnyType (TypeOfAny .from_omitted_generics )
72787284        return  Instance (node , [any_type ] *  len (node .defn .type_vars ))
72797285
@@ -7292,7 +7298,7 @@ def lookup_typeinfo(self, fullname: str) -> TypeInfo:
72927298        # Assume that the name refers to a class. 
72937299        sym  =  self .lookup_qualified (fullname )
72947300        node  =  sym .node 
7295-         assert  isinstance (node , TypeInfo )
7301+         assert  isinstance (node , TypeInfo ),  node 
72967302        return  node 
72977303
72987304    def  type_type (self ) ->  Instance :
@@ -7883,6 +7889,9 @@ def has_valid_attribute(self, typ: Type, name: str) -> bool:
78837889    def  get_expression_type (self , node : Expression , type_context : Type  |  None  =  None ) ->  Type :
78847890        return  self .expr_checker .accept (node , type_context = type_context )
78857891
7892+     def  is_defined_in_stub (self , typ : Instance , / ) ->  bool :
7893+         return  self .modules [typ .type .module_name ].is_stub 
7894+ 
78867895    def  check_deprecated (self , node : Node  |  None , context : Context ) ->  None :
78877896        """Warn if deprecated and not directly imported with a `from` statement.""" 
78887897        if  isinstance (node , Decorator ):
0 commit comments