Files
pydantic/docs
layday 78934db631 PropagateClassVars to sub-models (#2179)
* 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`
2021-02-13 14:52:39 +00:00
..
2020-04-15 16:40:21 +01:00
2019-10-14 16:40:25 +01:00
2019-10-14 16:40:25 +01:00
2019-10-07 17:19:01 +01:00
2020-10-09 12:52:08 +01:00
2019-10-07 17:19:01 +01:00
2020-10-09 13:06:47 +01:00
2019-10-07 17:19:01 +01:00