@@ -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 )
2957+ self .check_deprecated (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
@@ -7596,14 +7596,8 @@ def get_deprecation_warning(
75967596 return f"{ name } is deprecated: { deprecation } "
75977597 return f"{ name } is deprecated [overload { typ } ]: { deprecation } "
75987598
7599- def check_deprecated_function (self , typ : Type , context : Context ) -> None :
7600- if isinstance (typ := get_proper_type (typ ), (CallableType , Overloaded )):
7601- self ._check_deprecated (typ , context )
7602-
7603- def check_deprecated_class (self , typ : TypeInfo , context : Context ) -> None :
7604- self ._check_deprecated (typ , context )
7605-
7606- def _check_deprecated (self , typ : CallableType | Overloaded | TypeInfo , context : Context ) -> None :
7599+ def check_deprecated (self , typ : CallableType | Overloaded | TypeInfo , context : Context ) -> None :
7600+ """Warn if deprecated and not directly imported with a `from` statement."""
76077601 if typ .deprecated is not None :
76087602 for imp in self .tree .imports :
76097603 if isinstance (imp , ImportFrom ) and any (typ .name == n [0 ] for n in imp .names ):
@@ -7614,6 +7608,7 @@ def _check_deprecated(self, typ: CallableType | Overloaded | TypeInfo, context:
76147608 def warn_deprecated (
76157609 self , typ : CallableType | Overloaded | TypeInfo , context : Context
76167610 ) -> None :
7611+ """Warn if deprecated."""
76177612 if (deprecated := typ .deprecated ) is not None :
76187613 warn = self .msg .fail if self .options .report_deprecated_as_error else self .msg .note
76197614 warn (deprecated , context , code = codes .DEPRECATED )
0 commit comments