1from __future__ import annotations
2
3from typing import Annotated
4
5
6class _SecretMarker:
7 """Runtime marker for secret settings. Used as Annotated metadata."""
8
9 pass
10
11
12type Secret[T] = Annotated[T, _SecretMarker()]
13"""
14Marker type for sensitive settings. Values are masked in output/logs.
15
16Usage:
17 SECRET_KEY: Secret[str]
18 DATABASE_PASSWORD: Secret[str]
19
20At runtime, the value is still a plain str - this is purely for
21indicating that the setting should be masked when displayed.
22
23Secret[str] is a type alias for Annotated[str, _SecretMarker()],
24so type checkers see it as just str.
25"""