MCPcopy Index your code
hub / github.com/python/mypy / check_deprecated

Method check_deprecated

mypy/checker.py:8395–8406  ·  view source on GitHub ↗

Warn if deprecated and not directly imported with a `from` statement.

(self, node: Node | None, context: Context)

Source from the content-addressed store, hash-verified

8393 return self.modules[typ.type.module_name].is_stub
8394
8395 def check_deprecated(self, node: Node | None, context: Context) -> None:
8396 """Warn if deprecated and not directly imported with a `from` statement."""
8397 if isinstance(node, Decorator):
8398 node = node.func
8399 if isinstance(node, (FuncDef, OverloadedFuncDef, TypeInfo)) and (
8400 node.deprecated is not None
8401 ):
8402 for imp in self.tree.imports:
8403 if isinstance(imp, ImportFrom) and any(node.name == n[0] for n in imp.names):
8404 break
8405 else:
8406 self.warn_deprecated(node, context)
8407
8408 def warn_deprecated(self, node: Node | None, context: Context) -> None:
8409 """Warn if deprecated."""

Callers 1

visit_name_exprMethod · 0.45

Calls 3

warn_deprecatedMethod · 0.95
isinstanceFunction · 0.85
anyFunction · 0.85

Tested by

no test coverage detected