@@ -286,23 +286,16 @@ def check_frozenset_items_valid_literals(self, op: LoadLiteral, s: frozenset[obj
286286 self .fail (op , f"Invalid type for item of frozenset literal: { type (x )} )" )
287287
288288 def check_dict_items_valid_literals (self , op : LoadLiteral , d : dict [object , object ]) -> None :
289- key_types = (str , bytes , bool , int , float , complex , tuple )
290- value_types = (str , bytes , bool , int , float , complex , tuple , dict , frozenset )
289+ valid_types = (str , bytes , bool , int , float , complex )
291290 for k , v in d .items ():
292- # Acceptable key types: str, bytes, bool, int, float, complex, tuple, None
293- if k is not None and not isinstance (k , key_types ):
291+ # Acceptable key types: str, bytes, bool, int, float, complex
292+ if not isinstance (k , valid_types ):
294293 self .fail (op , f"Invalid type for key of dict literal: { type (k )} )" )
295294 if isinstance (k , tuple ):
296295 self .check_tuple_items_valid_literals (op , k )
297- # Acceptable value types: str, bytes, bool, int, float, complex, tuple, dict, frozenset, None
298- if v is not None and not isinstance (v , value_types ):
299- self .fail (op , f"Invalid type for value of dict literal: { type (v )} )" )
300- if isinstance (v , tuple ):
301- self .check_tuple_items_valid_literals (op , v )
302- elif isinstance (v , dict ):
303- self .check_dict_items_valid_literals (op , v )
304- elif isinstance (v , frozenset ):
305- self .check_frozenset_items_valid_literals (op , v )
296+ # Acceptable value types: str, bytes, bool, int, float, complex
297+ if not isinstance (v , valid_types ):
298+ self .fail (op , f"Invalid type for value of dict literal: { type (v )} )" ))
306299
307300 def visit_load_literal (self , op : LoadLiteral ) -> None :
308301 expected_type = None
0 commit comments