@@ -469,14 +469,14 @@ def visit_mapping_pattern(self, o: MappingPattern) -> PatternType:
469469 captures : dict [Expression , Type ] = {}
470470 for key , value in zip (o .keys , o .values ):
471471 inner_type = self .get_mapping_item_type (o , current_type , key )
472- if inner_type is None :
472+ if is_uninhabited ( inner_type ) :
473473 can_match = False
474- inner_type = self . chk . named_type ( "builtins.object" )
474+
475475 pattern_type = self .accept (value , inner_type )
476476 if is_uninhabited (pattern_type .type ):
477477 can_match = False
478- else :
479- self .update_type_map (captures , pattern_type .captures )
478+
479+ self .update_type_map (captures , pattern_type .captures )
480480
481481 if o .rest is not None :
482482 mapping = self .chk .named_type ("typing.Mapping" )
@@ -501,13 +501,13 @@ def visit_mapping_pattern(self, o: MappingPattern) -> PatternType:
501501
502502 def get_mapping_item_type (
503503 self , pattern : MappingPattern , mapping_type : Type , key : Expression
504- ) -> Type | None :
504+ ) -> Type :
505505 mapping_type = get_proper_type (mapping_type )
506506 if isinstance (mapping_type , TypedDictType ):
507507 with self .msg .filter_errors () as local_errors :
508- result : Type | None = self .chk .expr_checker .visit_typeddict_index_expr (
509- mapping_type , key
510- )[ 0 ]
508+ result : Type = self .chk .expr_checker .visit_typeddict_index_expr (mapping_type , key )[
509+ 0
510+ ]
511511 has_local_errors = local_errors .has_new_errors ()
512512 # If we can't determine the type statically fall back to treating it as a normal
513513 # mapping
@@ -516,7 +516,7 @@ def get_mapping_item_type(
516516 result = self .get_simple_mapping_item_type (pattern , mapping_type , key )
517517
518518 if local_errors .has_new_errors ():
519- result = None
519+ result = UninhabitedType ()
520520 else :
521521 with self .msg .filter_errors ():
522522 result = self .get_simple_mapping_item_type (pattern , mapping_type , key )
0 commit comments