mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
78934db631
* Propagate`ClassVar`s to sub-models
Currently, if a `ClassVar` is defined on a model and re-defined
on a sub-model omitting the `ClassVar` annotation, Pydantic produces an
unrelated error:
NameError: Field name "..." shadows a BaseModel attribute ...
This check was introduced to prevent shadowing Pydantic's own methods
and attributes defined on the `BaseModel` class. Following this change,
class variables (that is, variables annotated with `ClassVar`)
defined on parent models will be inherited by sub-models and
will be overwritable without having to reapply the annotation.
Closes #2061.
* docs: explain how attributes are excluded and when to use `PrivateAttr`