(
stub: nodes.FuncBase, runtime: Any, static_runtime: MaybeMissing[Any], object_path: list[str]
)
| 763 | |
| 764 | |
| 765 | def _verify_static_class_methods( |
| 766 | stub: nodes.FuncBase, runtime: Any, static_runtime: MaybeMissing[Any], object_path: list[str] |
| 767 | ) -> Iterator[str]: |
| 768 | if stub.name in ("__new__", "__init_subclass__", "__class_getitem__"): |
| 769 | # Special cased by Python, so don't bother checking |
| 770 | return |
| 771 | if inspect.isbuiltin(runtime): |
| 772 | # The isinstance checks don't work reliably for builtins, e.g. datetime.datetime.now, so do |
| 773 | # something a little hacky that seems to work well |
| 774 | probably_class_method = isinstance(getattr(runtime, "__self__", None), type) |
| 775 | if probably_class_method and not stub.is_class: |
| 776 | yield "runtime is a classmethod but stub is not" |
| 777 | if not probably_class_method and stub.is_class: |
| 778 | yield "stub is a classmethod but runtime is not" |
| 779 | return |
| 780 | |
| 781 | if static_runtime is MISSING: |
| 782 | return |
| 783 | |
| 784 | if isinstance(static_runtime, classmethod) and not stub.is_class: |
| 785 | yield "runtime is a classmethod but stub is not" |
| 786 | if not isinstance(static_runtime, classmethod) and stub.is_class: |
| 787 | yield "stub is a classmethod but runtime is not" |
| 788 | if isinstance(static_runtime, staticmethod) and not stub.is_static: |
| 789 | yield "runtime is a staticmethod but stub is not" |
| 790 | if not isinstance(static_runtime, staticmethod) and stub.is_static: |
| 791 | yield "stub is a staticmethod but runtime is not" |
| 792 | |
| 793 | |
| 794 | def _verify_arg_name( |
no test coverage detected
searching dependent graphs…