Coverage for /usr/local/lib/python3.12/site-packages/prefect/settings/__init__.py: 76%
13 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:38 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:38 +0000
1"""
2Prefect settings are defined using `BaseSettings` from `pydantic_settings`. `BaseSettings` can load setting values
3from system environment variables and each additionally specified `env_file`.
5The recommended user-facing way to access Prefect settings at this time is to import specific setting objects directly,
6like `from prefect.settings import PREFECT_API_URL; print(PREFECT_API_URL.value())`.
8Importantly, we replace the `callback` mechanism for updating settings with an "after" model_validator that updates dependent settings.
9After https://github.com/pydantic/pydantic/issues/9789 is resolved, we will be able to define context-aware defaults
10for settings, at which point we will not need to use the "after" model_validator.
11"""
13from typing import TYPE_CHECKING 1a
15from prefect.settings.models.root import Settings, canonical_environment_prefix 1a
17from prefect.settings.profiles import ( 1a
18 Profile,
19 ProfilesCollection,
20 load_current_profile,
21 update_current_profile,
22 load_profile,
23 save_profiles,
24 load_profiles,
25)
26from prefect.settings.context import get_current_settings, temporary_settings 1a
27from prefect.settings.constants import DEFAULT_PROFILES_PATH 1a
29if TYPE_CHECKING: 29 ↛ 30line 29 didn't jump to line 30 because the condition on line 29 was never true1a
30 from prefect.settings.legacy import Setting
31############################################################################
32# Allow traditional env var access
35def __getattr__(name: str) -> "Setting": 1a
36 from prefect.settings.legacy import ( 1ab
37 _get_settings_fields,
38 _get_valid_setting_names,
39 )
41 if name in _get_valid_setting_names(Settings): 41 ↛ 43line 41 didn't jump to line 43 because the condition on line 41 was always true1ab
42 return _get_settings_fields(Settings)[name] 1ab
43 raise AttributeError(f"{name} is not a Prefect setting.")
46__all__ = [ # noqa: F822 1a
47 "Profile",
48 "ProfilesCollection",
49 "Settings",
50 "load_current_profile",
51 "update_current_profile",
52 "load_profile",
53 "save_profiles",
54 "load_profiles",
55 "get_current_settings",
56 "temporary_settings",
57 "canonical_environment_prefix",
58 "DEFAULT_PROFILES_PATH",
59 # add public settings here for auto-completion
60 "PREFECT_API_AUTH_STRING", # type: ignore
61 "PREFECT_API_KEY", # type: ignore
62 "PREFECT_API_URL", # type: ignore
63 "PREFECT_UI_URL", # type: ignore
64]