Collects the values of the config attributes that are used by the plugin, accounting for parent classes.
(self)
| 342 | sym.node.func.is_class = True |
| 343 | |
| 344 | def collect_config(self) -> 'ModelConfigData': |
| 345 | """ |
| 346 | Collects the values of the config attributes that are used by the plugin, accounting for parent classes. |
| 347 | """ |
| 348 | ctx = self._ctx |
| 349 | cls = ctx.cls |
| 350 | config = ModelConfigData() |
| 351 | for stmt in cls.defs.body: |
| 352 | if not isinstance(stmt, ClassDef): |
| 353 | continue |
| 354 | if stmt.name == 'Config': |
| 355 | for substmt in stmt.defs.body: |
| 356 | if not isinstance(substmt, AssignmentStmt): |
| 357 | continue |
| 358 | config.update(self.get_config_update(substmt)) |
| 359 | if ( |
| 360 | config.has_alias_generator |
| 361 | and not config.allow_population_by_field_name |
| 362 | and self.plugin_config.warn_required_dynamic_aliases |
| 363 | ): |
| 364 | error_required_dynamic_aliases(ctx.api, stmt) |
| 365 | for info in cls.info.mro[1:]: # 0 is the current class |
| 366 | if METADATA_KEY not in info.metadata: |
| 367 | continue |
| 368 | |
| 369 | # Each class depends on the set of fields in its ancestors |
| 370 | ctx.api.add_plugin_dependency(make_wildcard_trigger(get_fullname(info))) |
| 371 | for name, value in info.metadata[METADATA_KEY]['config'].items(): |
| 372 | config.setdefault(name, value) |
| 373 | return config |
| 374 | |
| 375 | def collect_fields(self, model_config: 'ModelConfigData') -> List['PydanticModelField']: |
| 376 | """ |
no test coverage detected