Skip to content

Commit

Permalink
Merge branch 'feature/support_deprecated' of https://github.com/tyral…
Browse files Browse the repository at this point in the history
…la/mypy into feature/support_deprecated
  • Loading branch information
tyralla committed Aug 27, 2024
2 parents cf2dcaf + 6f54dab commit 6a93d6a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7578,7 +7578,8 @@ class that may be used later if the deprecated feature is used."""
overload = False
deprecation: str | None = None
for decorator in decorators:
if (isinstance(typ, CallableType)
if (
isinstance(typ, CallableType)
and isinstance(decorator, NameExpr)
and (decorator.fullname in OVERLOAD_NAMES)
):
Expand All @@ -7601,7 +7602,9 @@ class that may be used later if the deprecated feature is used."""
else:
typ.deprecated = f"{name} is deprecated: {deprecation}"

def check_deprecated(self, typ: CallableType | Overloaded | TypeInfo, context: Context) -> None:
def check_deprecated(
self, typ: CallableType | Overloaded | TypeInfo, context: Context
) -> None:
"""Warn if deprecated and not directly imported with a `from` statement."""
if typ.deprecated is not None:
for imp in self.tree.imports:
Expand All @@ -7610,9 +7613,7 @@ def check_deprecated(self, typ: CallableType | Overloaded | TypeInfo, context: C
else:
self.warn_deprecated(typ, context)

def warn_deprecated(
self, typ: CallableType | Overloaded | TypeInfo, context: Context
) -> None:
def warn_deprecated(self, typ: CallableType | Overloaded | TypeInfo, context: Context) -> None:
"""Warn if deprecated."""
if (deprecated := typ.deprecated) is not None:
warn = self.msg.fail if self.options.report_deprecated_as_error else self.msg.note
Expand Down

0 comments on commit 6a93d6a

Please sign in to comment.