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

Method process_deprecated_overload

mypy/semanal.py:1369–1396  ·  view source on GitHub ↗
(self, defn: OverloadedFuncDef)

Source from the content-addressed store, hash-verified

1367 self.process_overload_impl(defn)
1368
1369 def process_deprecated_overload(self, defn: OverloadedFuncDef) -> None:
1370 if defn.is_property:
1371 return
1372
1373 if isinstance(impl := defn.impl, Decorator) and (
1374 (deprecated := impl.func.deprecated) is not None
1375 ):
1376 defn.deprecated = deprecated
1377 for item in defn.items:
1378 if isinstance(item, Decorator):
1379 item.func.deprecated = deprecated
1380
1381 for item in defn.items:
1382 deprecation = False
1383 if isinstance(item, Decorator):
1384 for d in item.decorators:
1385 if deprecation and refers_to_fullname(d, OVERLOAD_NAMES):
1386 self.msg.note("@overload should be placed before @deprecated", d)
1387 elif (deprecated := self.get_deprecated(d)) is not None:
1388 deprecation = True
1389 if isinstance(typ := item.func.type, CallableType):
1390 typestr = f" {typ.accept(TypeStrVisitor(options=self.options))} "
1391 else:
1392 typestr = " "
1393 item.func.deprecated = (
1394 f"overload{typestr}of function {defn.fullname} is deprecated: "
1395 f"{deprecated}"
1396 )
1397
1398 @staticmethod
1399 def get_deprecated(expression: Expression) -> str | None:

Callers 1

Calls 6

get_deprecatedMethod · 0.95
TypeStrVisitorClass · 0.90
isinstanceFunction · 0.85
refers_to_fullnameFunction · 0.85
noteMethod · 0.45
acceptMethod · 0.45

Tested by

no test coverage detected