@@ -2473,15 +2473,22 @@ def magic_color_matcher(self, context: CompletionContext) -> SimpleMatcherResult
24732473
24742474 @context_matcher (identifier = "IPCompleter.jedi_matcher" )
24752475 def _jedi_matcher (self , context : CompletionContext ) -> _JediMatcherResult :
2476+ text = context .text_until_cursor
2477+ text = self ._extract_code (text )
2478+ completion_type = self ._determine_completion_context (text )
24762479 matches = self ._jedi_matches (
24772480 cursor_column = context .cursor_position ,
24782481 cursor_line = context .cursor_line ,
24792482 text = context .full_text ,
24802483 )
2484+ if completion_type == self ._CompletionContextType .ATTRIBUTE :
2485+ suppress = {_get_matcher_id (self .file_matcher )}
2486+ else :
2487+ suppress = False
24812488 return {
24822489 "completions" : matches ,
2483- # static analysis should not suppress other matchers
2484- "suppress" : { _get_matcher_id ( self . file_matcher )} if matches else False ,
2490+ # static analysis should not suppress other matchers except for file matcher
2491+ "suppress" : suppress ,
24852492 }
24862493
24872494 def _jedi_matches (
@@ -2744,8 +2751,7 @@ def python_matcher(self, context: CompletionContext) -> SimpleMatcherResult:
27442751 matches = _convert_matcher_v1_result_to_v2 (
27452752 matches , type = "attribute" , fragment = fragment
27462753 )
2747- if matches ["completions" ]:
2748- matches ["suppress" ] = {_get_matcher_id (self .file_matcher )}
2754+ matches ["suppress" ] = {_get_matcher_id (self .file_matcher )}
27492755 return matches
27502756 except NameError :
27512757 # catches <undefined attributes>.<tab>
@@ -3649,10 +3655,25 @@ def _complete(self, *, cursor_line, cursor_pos, line_buffer=None, text=None,
36493655 if isinstance (self .suppress_competing_matchers , dict )
36503656 else self .suppress_competing_matchers
36513657 )
3652- should_suppress = (
3653- (suppression_config is True )
3654- or (suppression_recommended and (suppression_config is not False ))
3655- ) and has_any_completions (result )
3658+ file_matcher_id = _get_matcher_id (self .file_matcher )
3659+ python_matcher_id = _get_matcher_id (self .python_matcher )
3660+ jedi_matcher_id = _get_matcher_id (self ._jedi_matcher )
3661+ # If this is attribute completion and it explicitly
3662+ # recommends suppressing the file matcher, do so.
3663+ if (
3664+ (matcher_id == python_matcher_id or matcher_id == jedi_matcher_id )
3665+ and isinstance (suppression_recommended , set )
3666+ and file_matcher_id in suppression_recommended
3667+ ):
3668+ should_suppress = True
3669+ else :
3670+ should_suppress = (
3671+ (suppression_config is True )
3672+ or (
3673+ suppression_recommended
3674+ and (suppression_config is not False )
3675+ )
3676+ ) and has_any_completions (result )
36563677
36573678 if should_suppress :
36583679 suppression_exceptions : set [str ] = result .get (
0 commit comments