Check if `defn` can _only_ return None.
(self, defn: SymbolNode | None)
| 730 | return False |
| 731 | |
| 732 | def defn_returns_none(self, defn: SymbolNode | None) -> bool: |
| 733 | """Check if `defn` can _only_ return None.""" |
| 734 | if isinstance(defn, FuncDef): |
| 735 | return isinstance(defn.type, CallableType) and isinstance( |
| 736 | get_proper_type(defn.type.ret_type), NoneType |
| 737 | ) |
| 738 | if isinstance(defn, OverloadedFuncDef): |
| 739 | return all(self.defn_returns_none(item) for item in defn.items) |
| 740 | if isinstance(defn, Var): |
| 741 | typ = get_proper_type(defn.type) |
| 742 | if ( |
| 743 | not defn.is_inferred |
| 744 | and isinstance(typ, CallableType) |
| 745 | and isinstance(get_proper_type(typ.ret_type), NoneType) |
| 746 | ): |
| 747 | return True |
| 748 | if isinstance(typ, Instance): |
| 749 | sym = typ.type.get("__call__") |
| 750 | if sym and self.defn_returns_none(sym.node): |
| 751 | return True |
| 752 | return False |
| 753 | |
| 754 | def check_runtime_protocol_test(self, e: CallExpr) -> None: |
| 755 | for expr in mypy.checker.flatten(e.args[1]): |
no test coverage detected