Analyze the class body, its parents, and return the comparison methods found.
(ctx: mypy.plugin.ClassDefContext)
| 111 | |
| 112 | |
| 113 | def _analyze_class(ctx: mypy.plugin.ClassDefContext) -> dict[str, _MethodInfo | None]: |
| 114 | """Analyze the class body, its parents, and return the comparison methods found.""" |
| 115 | # Traverse the MRO and collect ordering methods. |
| 116 | comparison_methods: dict[str, _MethodInfo | None] = {} |
| 117 | # Skip object because total_ordering does not use methods from object |
| 118 | for cls in ctx.cls.info.mro[:-1]: |
| 119 | for name in _ORDERING_METHODS: |
| 120 | if name in cls.names and name not in comparison_methods: |
| 121 | node = cls.names[name].node |
| 122 | if isinstance(node, SYMBOL_FUNCBASE_TYPES) and isinstance(node.type, CallableType): |
| 123 | comparison_methods[name] = _MethodInfo(node.is_static, node.type) |
| 124 | continue |
| 125 | |
| 126 | if isinstance(node, Var): |
| 127 | proper_type = get_proper_type(node.type) |
| 128 | if isinstance(proper_type, CallableType): |
| 129 | comparison_methods[name] = _MethodInfo(node.is_staticmethod, proper_type) |
| 130 | continue |
| 131 | |
| 132 | comparison_methods[name] = None |
| 133 | |
| 134 | return comparison_methods |
| 135 | |
| 136 | |
| 137 | def partial_new_callback(ctx: mypy.plugin.FunctionContext) -> Type: |
no test coverage detected
searching dependent graphs…