Generate error about missing overload implementation (only if needed).
(self, defn: OverloadedFuncDef)
| 1502 | del defn.items[idx] |
| 1503 | |
| 1504 | def handle_missing_overload_implementation(self, defn: OverloadedFuncDef) -> None: |
| 1505 | """Generate error about missing overload implementation (only if needed).""" |
| 1506 | if not self.is_stub_file: |
| 1507 | if self.type and self.type.is_protocol and not self.is_func_scope(): |
| 1508 | # An overloaded protocol method doesn't need an implementation, |
| 1509 | # but if it doesn't have one, then it is considered abstract. |
| 1510 | for item in defn.items: |
| 1511 | if isinstance(item, Decorator): |
| 1512 | item.func.abstract_status = IS_ABSTRACT |
| 1513 | else: |
| 1514 | item.abstract_status = IS_ABSTRACT |
| 1515 | elif all( |
| 1516 | isinstance(item, Decorator) and item.func.abstract_status == IS_ABSTRACT |
| 1517 | for item in defn.items |
| 1518 | ): |
| 1519 | # Since there is no implementation, it can't be called via super(). |
| 1520 | if defn.items: |
| 1521 | assert isinstance(defn.items[0], Decorator) |
| 1522 | defn.items[0].func.is_trivial_body = True |
| 1523 | else: |
| 1524 | self.fail( |
| 1525 | "An overloaded function outside a stub file must have an implementation", |
| 1526 | defn, |
| 1527 | code=codes.NO_OVERLOAD_IMPL, |
| 1528 | ) |
| 1529 | |
| 1530 | def process_final_in_overload(self, defn: OverloadedFuncDef) -> None: |
| 1531 | """Detect the @final status of an overloaded function (and perform checks).""" |
no test coverage detected