mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
c24d33e5f1
* Generate docs exampels for Python 3.10 and above Code quality is not great and main intent here is to show the result. * Fix docs build on 3.9 * Build docs on 3.10 * What's Python 3.1? * Create temp dir if not exists * Refactor and improve imlementetion * Keep runtime typing in examples * Revert unrelated formatting changes * Add changes file * Allow specifying requirements in examples * Pin autoflake and pyupgrade * Add docs/build to Makefile lint/format/mypy * ignore_missing_imports for ansi2html and devtools * Add .tmp-projections to .gitignore * Remove dont-upgrade now when Pattern is supported * Update postponed evaluation examples Co-authored-by: Samuel Colvin <s@muelcolvin.com>
24 lines
713 B
Python
24 lines
713 B
Python
from typing import Tuple
|
|
|
|
from pydantic import BaseSettings
|
|
from pydantic.env_settings import SettingsSourceCallable
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
my_api_key: str
|
|
|
|
class Config:
|
|
@classmethod
|
|
def customise_sources(
|
|
cls,
|
|
init_settings: SettingsSourceCallable,
|
|
env_settings: SettingsSourceCallable,
|
|
file_secret_settings: SettingsSourceCallable,
|
|
) -> Tuple[SettingsSourceCallable, ...]:
|
|
# here we choose to ignore arguments from init_settings
|
|
return env_settings, file_secret_settings
|
|
|
|
|
|
print(Settings(my_api_key='this is ignored'))
|
|
# requires: `MY_API_KEY` env variable to be set, e.g. `export MY_API_KEY=xxx`
|