(cls: ClassDef, name: str)
| 303 | |
| 304 | |
| 305 | def _prepare_class_namespace(cls: ClassDef, name: str) -> None: |
| 306 | info = cls.info |
| 307 | assert info |
| 308 | |
| 309 | # First remove any previously generated methods with the same name |
| 310 | # to avoid clashes and problems in the semantic analyzer. |
| 311 | if name in info.names: |
| 312 | sym = info.names[name] |
| 313 | if sym.plugin_generated and isinstance(sym.node, FuncDef): |
| 314 | cls.defs.body.remove(sym.node) |
| 315 | |
| 316 | # NOTE: we would like the plugin generated node to dominate, but we still |
| 317 | # need to keep any existing definitions so they get semantically analyzed. |
| 318 | if name in info.names: |
| 319 | # Get a nice unique name instead. |
| 320 | r_name = get_unique_redefinition_name(name, info.names) |
| 321 | info.names[r_name] = info.names[name] |
| 322 | |
| 323 | |
| 324 | def _add_method_by_spec( |
no test coverage detected
searching dependent graphs…