(
value, allowed_types, allowed_methods, allowed_external, method_name
)
| 198 | |
| 199 | |
| 200 | def _has_original_dunder( |
| 201 | value, allowed_types, allowed_methods, allowed_external, method_name |
| 202 | ): |
| 203 | # note: Python ignores `__getattr__`/`__getitem__` on instances, |
| 204 | # we only need to check at class level |
| 205 | value_type = type(value) |
| 206 | |
| 207 | # strict type check passes → no need to check method |
| 208 | if value_type in allowed_types: |
| 209 | return True |
| 210 | |
| 211 | method = getattr(value_type, method_name, None) |
| 212 | |
| 213 | if method is None: |
| 214 | return None |
| 215 | |
| 216 | if method in allowed_methods: |
| 217 | return True |
| 218 | |
| 219 | for module_name, *access_path in allowed_external: |
| 220 | if _has_original_dunder_external(value, module_name, access_path, method_name): |
| 221 | return True |
| 222 | |
| 223 | return False |
| 224 | |
| 225 | |
| 226 | def _coerce_path_to_tuples( |
no test coverage detected
searching dependent graphs…