Current collected state Current
Observed since 20 Oct, 15:12 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Like dataclasses but for config.
Like dataclasses but for config.
Specify your config with a class and load it with your env vars or env files.
# .env
HOST=0.0.0.0
PORT=8000
...
import httpx
from configclasses import configclass
@configclass
class ClientConfig:
host: str
port: int
class UserAPIClient(httpx.AsyncClient):
def __init__(self, config: ClientConfig, *args, **kwargs):
self.config = config
...
config = ClientConfig.from_path(".env")
async with UserAPIClient(config) as client:
...
int, float, str or bool.@configclass(prefix="<PREFIX>") to append this prefix to your configclass' attribute names.Python 3.8+
Depending on your chosen config file format you can install:
pip install 12factor-configclasses[dotenv]pip install 12factor-configclasses[yaml]pip install 12factor-configclasses[toml]pip install 12factor-configclassespip install 12factor-configclassesOr install all supported formats with:
pip install 12factor-configclasses[full]
There are three ways to use it.
# .env
HOST=0.0.0.0
PORT=8000
DB_URL=sqlite://:memory:
GENERATE_SCHEMAS=True
DEBUG=True
HTTPS_ONLY=False
GZIP=True
SENTRY=False
#config.py
from configclasses import configclass
@configclass
class DB:
user: str
password: str
url: str
@configclass
class AppConfig:
host: str
port: int
db: DB
generate_schemas: bool
debug: bool
https_only: bool
gzip: bool
sentry: bool
# app.py
from api.config import AppConfig
app_config = AppConfig.from_path(".env")
app = Starlette(debug=app_config.debug)
if app_config.https_only:
app.add_middleware(
HTTPSRedirectMiddleware)
if app_config.gzip:
app.add_middleware(GZipMiddleware)
if app_config.sentry:
app.add_middleware(SentryAsgiMiddleware)
...
register_tortoise(
app,
db_url=app_config.db.url,
modules={"models": ["api.models"]},
generate_schemas=app_config.generate_schemas,
)
if __name__ == "__main__":
uvicorn.run(app, host=app_config.host, port=app_config.port)
The same than before, but instead of:
app_config = AppConfig.from_path(".env")
You will do:
app_config = AppConfig.from_environ()
test_env = """HOST=0.0.0.0
PORT=8000
DB_URL=sqlite://:memory:
GENERATE_SCHEMAS=True
DEBUG=True
HTTPS_ONLY=False
GZIP=True
SENTRY=False"""
app_config = AppConfig.from_string(test_env, ".env")
pypistats · 86 observations shown. Missing days are unknown. Source category: overall: without mirrors.
| Date / source period | Value | Observed at |
|---|---|---|
| 2026-10-19 – 2026-10-19 | 5 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-18 – 2026-10-18 | 4 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-17 – 2026-10-17 | 11 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-16 – 2026-10-16 | 24 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-15 – 2026-10-15 | 16 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-14 – 2026-10-14 | 14 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-13 – 2026-10-13 | 5 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-12 – 2026-10-12 | 15 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-11 – 2026-10-11 | 5 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-10 – 2026-10-10 | 8 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-09 – 2026-10-09 | 74 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-08 – 2026-10-08 | 8 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-07 – 2026-10-07 | 4 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-06 – 2026-10-06 | 15 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-05 – 2026-10-05 | 1 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-02 – 2026-10-02 | 15 | 2026-10-20T17:55:47.0496303Z |
| 2026-10-01 – 2026-10-01 | 11 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-30 – 2026-09-30 | 15 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-29 – 2026-09-29 | 32 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-28 – 2026-09-28 | 45 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-27 – 2026-09-27 | 9 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-26 – 2026-09-26 | 44 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-25 – 2026-09-25 | 51 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-24 – 2026-09-24 | 54 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-23 – 2026-09-23 | 16 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-22 – 2026-09-22 | 17 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-21 – 2026-09-21 | 31 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-20 – 2026-09-20 | 36 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-19 – 2026-09-19 | 1 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-18 – 2026-09-18 | 13 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-17 – 2026-09-17 | 18 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-16 – 2026-09-16 | 21 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-15 – 2026-09-15 | 19 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-14 – 2026-09-14 | 14 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-13 – 2026-09-13 | 5 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-12 – 2026-09-12 | 14 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-11 – 2026-09-11 | 17 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-10 – 2026-09-10 | 17 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-09 – 2026-09-09 | 4 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-08 – 2026-09-08 | 9 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-07 – 2026-09-07 | 8 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-06 – 2026-09-06 | 2 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-05 – 2026-09-05 | 4 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-04 – 2026-09-04 | 34 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-03 – 2026-09-03 | 27 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-02 – 2026-09-02 | 48 | 2026-10-20T17:55:47.0496303Z |
| 2026-09-01 – 2026-09-01 | 36 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-31 – 2026-08-31 | 19 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-29 – 2026-08-29 | 10 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-28 – 2026-08-28 | 28 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-27 – 2026-08-27 | 15 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-26 – 2026-08-26 | 33 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-25 – 2026-08-25 | 20 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-24 – 2026-08-24 | 29 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-23 – 2026-08-23 | 13 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-22 – 2026-08-22 | 11 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-21 – 2026-08-21 | 36 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-20 – 2026-08-20 | 14 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-19 – 2026-08-19 | 17 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-18 – 2026-08-18 | 115 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-17 – 2026-08-17 | 42 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-16 – 2026-08-16 | 2 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-15 – 2026-08-15 | 6 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-14 – 2026-08-14 | 62 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-13 – 2026-08-13 | 29 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-12 – 2026-08-12 | 15 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-11 – 2026-08-11 | 33 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-10 – 2026-08-10 | 16 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-09 – 2026-08-09 | 19 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-08 – 2026-08-08 | 11 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-07 – 2026-08-07 | 25 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-06 – 2026-08-06 | 39 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-05 – 2026-08-05 | 14 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-04 – 2026-08-04 | 28 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-03 – 2026-08-03 | 45 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-02 – 2026-08-02 | 3 | 2026-10-20T17:55:47.0496303Z |
| 2026-08-01 – 2026-08-01 | 7 | 2026-10-20T17:55:47.0496303Z |
| 2026-07-31 – 2026-07-31 | 30 | 2026-10-20T17:55:47.0496303Z |
| 2026-07-30 – 2026-07-30 | 51 | 2026-10-20T17:55:47.0496303Z |
| 2026-07-29 – 2026-07-29 | 49 | 2026-10-20T17:55:47.0496303Z |
| 2026-07-28 – 2026-07-28 | 30 | 2026-10-20T17:55:47.0496303Z |
| 2026-07-27 – 2026-07-27 | 33 | 2026-10-20T17:55:47.0496303Z |
| 2026-07-25 – 2026-07-25 | 2 | 2026-10-20T17:55:47.0496303Z |
| 2026-07-24 – 2026-07-24 | 36 | 2026-10-20T17:55:47.0496303Z |
| 2026-07-23 – 2026-07-23 | 21 | 2026-10-20T17:55:47.0496303Z |
| 2026-07-22 – 2026-07-22 | 19 | 2026-10-20T17:55:47.0496303Z |
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 2.0.1 | 18 Oct 2023 | 3 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 15:12 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:1d2fe21a7454d4b14cbc1b4e68079a3afb1f86da5cc8c321c3fb06783ceb0363