MCPcopy
hub / github.com/pydantic/pydantic / __getattr__

Function __getattr__

pydantic/__init__.py:425–452  ·  view source on GitHub ↗
(attr_name: str)

Source from the content-addressed store, hash-verified

423
424
425def __getattr__(attr_name: str) -> object:
426 if attr_name in _deprecated_dynamic_imports:
427 from pydantic.warnings import PydanticDeprecatedSince20
428
429 warn(
430 f'Importing {attr_name} from `pydantic` is deprecated. This feature is either no longer supported, or is not public.',
431 PydanticDeprecatedSince20,
432 stacklevel=2,
433 )
434
435 dynamic_attr = _dynamic_imports.get(attr_name)
436 if dynamic_attr is None:
437 return _getattr_migration(attr_name)
438
439 package, module_name = dynamic_attr
440
441 if module_name == '__module__':
442 result = import_module(f'.{attr_name}', package=package)
443 globals()[attr_name] = result
444 return result
445 else:
446 module = import_module(module_name, package=package)
447 result = getattr(module, attr_name)
448 g = globals()
449 for k, (_, v_module_name) in _dynamic_imports.items():
450 if v_module_name == module_name and k not in _deprecated_dynamic_imports:
451 g[k] = getattr(module, k)
452 return result
453
454
455def __dir__() -> list[str]:

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected