@@ -53,6 +53,30 @@ Set it to `0` when the surrounding environment (CI secrets, systemd `Environment
5353export AUTOREAD_ENFORCE_DOTENV=0
5454```
5555
56+ ## ` AUTOREAD_DOTENV_QUIET `
57+
58+ Suppress every warning ` autoread-dotenv ` emits. When truthy, [ ` entrypoint() ` ] ( reference/index.md )
59+ installs a process-wide ` ignore ` filter for the
60+ [ ` AutoreadDotenvWarning ` ] ( reference/warnings.md ) category before it does anything else.
61+
62+ - ** Default:** ` 0 ` (false) - warnings are shown.
63+ - ** True values:** ` 1 ` , ` true ` , ` yes ` (case-insensitive).
64+ - ** False values:** ` 0 ` , ` false ` , ` no ` , ` "" ` (empty).
65+ - ** Anything else:** treated as false, * and a warning is emitted* (typo guard) - so a
66+ misspelled value like ` AUTOREAD_DOTENV_QUIET=ture ` still warns once.
67+ - ** Read by:** [ ` entrypoint() ` ] ( reference/index.md ) , parsed via
68+ [ ` str_to_bool() ` ] ( reference/utils.md ) ; the name lives in
69+ ` autoread_dotenv.utils.AUTOREAD_DOTENV_QUIET_VAR ` .
70+
71+ ``` bash
72+ export AUTOREAD_DOTENV_QUIET=1
73+ ```
74+
75+ This is the blunt instrument: it hides the missing-` .env ` notice together with the genuine
76+ misconfiguration warnings (` python-dotenv ` not installed, an unreadable ` .env ` , a typo'd
77+ boolean elsewhere). Reach for it when the process legitimately runs without a ` .env ` and you
78+ have accepted that trade-off; otherwise prefer removing the cause (see below).
79+
5680## Silencing warnings
5781
5882` autoread-dotenv ` never raises for a configuration problem - it emits a warning and records
@@ -82,19 +106,22 @@ of your code. An in-process `filterwarnings()` call therefore only affects a lat
82106` entrypoint() ` invocation - it cannot retroactively silence the startup pass. Use the options
83107in the next section for that.
84108
85- ### At startup ( ` PYTHONWARNINGS ` / ` -W ` )
109+ ### At startup
86110
87- ` PYTHONWARNINGS ` and ` -W ` ** cannot** name ` AutoreadDotenvWarning ` . The interpreter parses
88- warning filters before ` site ` puts ` site-packages ` on ` sys.path ` , so a third-party category
89- cannot be imported yet and the whole filter is silently dropped
90- (` Invalid -W option ignored: invalid module name: 'autoread_dotenv' ` ). Only built-in
91- categories resolve there:
111+ Set [ ` AUTOREAD_DOTENV_QUIET=1 ` ] ( #autoread_dotenv_quiet ) . It is read at the very top of
112+ ` entrypoint() ` , so it covers the startup pass that an in-process ` filterwarnings() ` call
113+ misses:
92114
93115``` bash
94- # broad - silences every UserWarning in the process, not just ours
95- export PYTHONWARNINGS=" ignore::UserWarning"
116+ export AUTOREAD_DOTENV_QUIET=1
96117```
97118
119+ ` PYTHONWARNINGS ` and ` -W ` are * not* an option here: they ** cannot** name
120+ ` AutoreadDotenvWarning ` . The interpreter parses warning filters before ` site ` puts
121+ ` site-packages ` on ` sys.path ` , so a third-party category cannot be imported yet and the whole
122+ filter is silently dropped (` Invalid -W option ignored: invalid module name: 'autoread_dotenv' ` ).
123+ Only built-in categories resolve there, so the closest ` PYTHONWARNINGS ` equivalent is the much broader ` ignore::UserWarning ` .
124+
98125### Better: remove the cause
99126
100127The most common warning is the missing-` .env ` notice. Rather than muting it, point the loader
0 commit comments