From cb7f0781473e874fc893dfe888793a9a9e8022e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Mon, 6 Sep 2021 12:13:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20autocomplete=20support=20for?= =?UTF-8?q?=20VS=20Code,=20via=20`dataclass=5Ftransform`=20(#2721)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Add autocomplete support for VS Code, via dataclass_transform * 📝 Update changes * 📝 Add docs for VS Code * 📝 Clarify strict type error checks alternatives, include example with cast() * ♻️ Update BaseSettings annotation to improve editor support keeping editor support for BaseSetting's custom Config, but preventing __config__ from showing in constructor on editors supporting dataclass_transform * 🎨 Remove unused type: ignore comment * 🎨 Update type annotations for BaseSettings and BaseModel to use ClassVar where suitable to improve editor support with type annotations and dataclass_transform * 🎨 Apply ClassVars again * 📝 Simplify VS Code docs terms refer mainly to Pylance and clarify the relationship with Pyright * 📝 Add link to Pylance FAQ Co-authored-by: PrettyWood --- pydantic/main.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pydantic/main.py b/pydantic/main.py index 9648bffb43..a25e96efea 100644 --- a/pydantic/main.py +++ b/pydantic/main.py @@ -127,18 +127,6 @@ def hash_function(self_: Any) -> int: _is_base_model_class_defined = False -_T = TypeVar('_T') - - -def __dataclass_transform__( - *, - eq_default: bool = True, - order_default: bool = False, - kw_only_default: bool = False, - field_descriptors: Tuple[Union[type, Callable[..., Any]], ...] = (()), -) -> Callable[[_T], _T]: - return lambda a: a - @__dataclass_transform__(kw_only_default=True, field_descriptors=(Field, FieldInfo)) class ModelMetaclass(ABCMeta): @no_type_check # noqa C901