(stub: nodes.Decorator, runtime: Any)
| 1488 | |
| 1489 | |
| 1490 | def _verify_readonly_property(stub: nodes.Decorator, runtime: Any) -> Iterator[str]: |
| 1491 | assert stub.func.is_property |
| 1492 | if isinstance(runtime, property): |
| 1493 | yield from _verify_final_method(stub.func, runtime.fget, MISSING) |
| 1494 | return |
| 1495 | if isinstance(runtime, functools.cached_property): |
| 1496 | yield from _verify_final_method(stub.func, runtime.func, MISSING) |
| 1497 | return |
| 1498 | if _is_django_cached_property(runtime): |
| 1499 | yield from _verify_final_method(stub.func, runtime.func, MISSING) |
| 1500 | return |
| 1501 | if inspect.isdatadescriptor(runtime): |
| 1502 | # It's enough like a property... |
| 1503 | return |
| 1504 | # Sometimes attributes pretend to be properties, for instance, to express that they |
| 1505 | # are read only. So allowlist if runtime_type matches the return type of stub. |
| 1506 | runtime_type = get_mypy_type_of_runtime_value(runtime) |
| 1507 | func_type = ( |
| 1508 | stub.func.type.ret_type if isinstance(stub.func.type, mypy.types.CallableType) else None |
| 1509 | ) |
| 1510 | if ( |
| 1511 | runtime_type is not None |
| 1512 | and func_type is not None |
| 1513 | and is_subtype_helper(runtime_type, func_type) |
| 1514 | ): |
| 1515 | return |
| 1516 | yield "is inconsistent, cannot reconcile @property on stub with runtime object" |
| 1517 | |
| 1518 | |
| 1519 | def _verify_abstract_status(stub: nodes.FuncDef, runtime: Any) -> Iterator[str]: |
no test coverage detected
searching dependent graphs…