Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add autocomplete support for VS Code, via dataclass_transform #2721

Merged
merged 13 commits into from Sep 6, 2021
7 changes: 5 additions & 2 deletions pydantic/env_settings.py
@@ -1,7 +1,7 @@
import os
import warnings
from pathlib import Path
from typing import AbstractSet, Any, Callable, Dict, List, Mapping, Optional, Tuple, Union
from typing import TYPE_CHECKING, AbstractSet, Any, Callable, Dict, List, Mapping, Optional, Tuple, Type, Union

from .fields import ModelField
from .main import BaseConfig, BaseModel, Extra
Expand Down Expand Up @@ -113,7 +113,10 @@ def customise_sources(
) -> Tuple[SettingsSourceCallable, ...]:
return init_settings, env_settings, file_secret_settings

__config__: Config # type: ignore
if TYPE_CHECKING:
# populated by the metaclass using the Config class defined above, annotated here to help IDEs only
# inside a TYPE_CHECKING block to avoid showing it in __init__ by IDEs supporting dataclass_transform
__config__: Type[Config]
tiangolo marked this conversation as resolved.
Show resolved Hide resolved


class InitSettingsSource:
Expand Down