@@ -2856,8 +2856,8 @@ def visit_import_from(self, node: ImportFrom) -> None:
28562856 if (sym := self .globals .get (name )) is not None :
28572857 if isinstance (sym .node , TypeInfo ):
28582858 self .warn_deprecated (sym .node , node )
2859- elif isinstance (co := get_proper_type (sym .type ), (CallableType , Overloaded )):
2860- self .warn_deprecated (co , node )
2859+ elif isinstance (typ := get_proper_type (sym .type ), (CallableType , Overloaded )):
2860+ self .warn_deprecated (typ , node )
28612861 self .check_import (node )
28622862
28632863 def visit_import_all (self , node : ImportAll ) -> None :
@@ -2954,7 +2954,7 @@ def visit_assignment_stmt(self, s: AssignmentStmt) -> None:
29542954 and isinstance (var := lvalue .node , Var )
29552955 and isinstance (instance := get_proper_type (var .type ), Instance )
29562956 ):
2957- self .check_deprecated_class (instance .type , s , False )
2957+ self .check_deprecated_class (instance .type , s )
29582958
29592959 # Avoid type checking type aliases in stubs to avoid false
29602960 # positives about modern type syntax available in stubs such
@@ -4700,7 +4700,8 @@ def visit_operator_assignment_stmt(self, s: OperatorAssignmentStmt) -> None:
47004700 if inplace :
47014701 # There is __ifoo__, treat as x = x.__ifoo__(y)
47024702 rvalue_type , method_type = self .expr_checker .check_op (method , lvalue_type , s .rvalue , s )
4703- self .check_deprecated_function (method_type , s , True )
4703+ if isinstance (method_type := get_proper_type (method_type ), (CallableType , Overloaded )):
4704+ self .warn_deprecated (method_type , s )
47044705 if not is_subtype (rvalue_type , lvalue_type ):
47054706 self .msg .incompatible_operator_assignment (s .op , s )
47064707 else :
@@ -7595,19 +7596,15 @@ def get_deprecation_warning(
75957596 return f"{ name } is deprecated: { deprecation } "
75967597 return f"{ name } is deprecated [overload { typ } ]: { deprecation } "
75977598
7598- def check_deprecated_function (self , typ : Type , context : Context , memberaccess : bool ) -> None :
7599+ def check_deprecated_function (self , typ : Type , context : Context ) -> None :
75997600 if isinstance (typ := get_proper_type (typ ), (CallableType , Overloaded )):
7600- self ._check_deprecated (typ , context , memberaccess )
7601+ self ._check_deprecated (typ , context )
76017602
7602- def check_deprecated_class (self , typ : TypeInfo , context : Context , memberaccess : bool ) -> None :
7603- self ._check_deprecated (typ , context , memberaccess )
7603+ def check_deprecated_class (self , typ : TypeInfo , context : Context ) -> None :
7604+ self ._check_deprecated (typ , context )
76047605
7605- def _check_deprecated (
7606- self , typ : CallableType | Overloaded | TypeInfo , context : Context , memberaccess : bool
7607- ) -> None :
7608- if memberaccess :
7609- self .warn_deprecated (typ , context )
7610- elif typ .deprecated is not None :
7606+ def _check_deprecated (self , typ : CallableType | Overloaded | TypeInfo , context : Context ) -> None :
7607+ if typ .deprecated is not None :
76117608 for imp in self .tree .imports :
76127609 if isinstance (imp , ImportFrom ) and any (typ .name == n [0 ] for n in imp .names ):
76137610 break
0 commit comments