MCPcopy
hub / github.com/pydantic/pydantic / collect_config

Method collect_config

pydantic/v1/mypy.py:344–373  ·  view source on GitHub ↗

Collects the values of the config attributes that are used by the plugin, accounting for parent classes.

(self)

Source from the content-addressed store, hash-verified

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 """

Callers 1

transformMethod · 0.95

Calls 7

updateMethod · 0.95
get_config_updateMethod · 0.95
setdefaultMethod · 0.95
get_fullnameFunction · 0.85
ModelConfigDataClass · 0.70
itemsMethod · 0.45

Tested by

no test coverage detected