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

Method process_overload_impl

mypy/semanal.py:1409–1423  ·  view source on GitHub ↗

Set flags for an overload implementation. Currently, this checks for a trivial body in protocols classes, where it makes the method implicitly abstract.

(self, defn: OverloadedFuncDef)

Source from the content-addressed store, hash-verified

1407 return None
1408
1409 def process_overload_impl(self, defn: OverloadedFuncDef) -> None:
1410 """Set flags for an overload implementation.
1411
1412 Currently, this checks for a trivial body in protocols classes,
1413 where it makes the method implicitly abstract.
1414 """
1415 if defn.impl is None:
1416 return
1417 impl = defn.impl if isinstance(defn.impl, FuncDef) else defn.impl.func
1418 if is_trivial_body(impl.body) and self.is_class_scope() and not self.is_stub_file:
1419 assert self.type is not None
1420 if self.type.is_protocol:
1421 impl.abstract_status = IMPLICITLY_ABSTRACT
1422 if impl.abstract_status != NOT_ABSTRACT:
1423 impl.is_trivial_body = True
1424
1425 def analyze_overload_sigs_and_impl(
1426 self, defn: OverloadedFuncDef

Callers 1

Calls 3

is_class_scopeMethod · 0.95
isinstanceFunction · 0.85
is_trivial_bodyFunction · 0.85

Tested by

no test coverage detected