From 6376d7e64ee732ceeac7cefe71b23766c60b5167 Mon Sep 17 00:00:00 2001 From: layday Date: Sun, 19 Dec 2021 02:02:36 +0200 Subject: [PATCH 1/2] Remove `__root__` from BaseModel typing-only attrs `__root__` is not a class variable nor is it always present. The switch to `ClassVar` caused type errors to be reported in Pylance/Pyright. --- pydantic/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pydantic/main.py b/pydantic/main.py index 02bebc4608..62dc0bb3e2 100644 --- a/pydantic/main.py +++ b/pydantic/main.py @@ -306,7 +306,6 @@ class BaseModel(Representation, metaclass=ModelMetaclass): __pre_root_validators__: ClassVar[List[AnyCallable]] __post_root_validators__: ClassVar[List[Tuple[bool, AnyCallable]]] __config__: ClassVar[Type[BaseConfig]] = BaseConfig - __root__: ClassVar[Any] = None __json_encoder__: ClassVar[Callable[[Any], Any]] = lambda x: x __schema_cache__: ClassVar['DictAny'] = {} __custom_root_type__: ClassVar[bool] = False From bf77fd30b2c1e03bdbf1b35a455c44626f3b72e0 Mon Sep 17 00:00:00 2001 From: layday Date: Sun, 19 Dec 2021 02:03:51 +0200 Subject: [PATCH 2/2] Add changelog entry --- changes/3540-layday.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/3540-layday.md diff --git a/changes/3540-layday.md b/changes/3540-layday.md new file mode 100644 index 0000000000..9a3fcdd68b --- /dev/null +++ b/changes/3540-layday.md @@ -0,0 +1 @@ +Removed typing-only `__root__` attribute from `BaseModel`