Config convention: env only via pydantic-settings, secrets as SecretStr — os.environ banned by lint#41
Merged
Merged
Conversation
…r; os.environ banned by lint - requirements_v3 §Code: configuration enters only through pydantic-settings (BaseSettings), typed and validated in one place; direct os.environ/os.getenv is banned; secrets are SecretStr/SecretBytes, unwrapped only at the call site - pyproject: enforce mechanically via ruff TID251 banned-api (os.environ, os.getenv, os.putenv) with messages pointing at requirements §Code; verified the rule fires on a deliberate violation Tests still set env via pytest monkeypatch.setenv (not banned). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the configuration rule binding and mechanically enforced, per the author's direction:
requirements_v3.md§Code — all configuration enters through pydantic-settings (BaseSettings): env vars are read in exactly one place as typed, validated settings. Secrets areSecretStr/SecretBytes(can't leak into logs/reprs/tracebacks), unwrapped via.get_secret_value()only at the call site that needs them.TID251banned-api —os.environ,os.getenv,os.putenvare lint errors with messages pointing at the requirement. Verified: a deliberate violation failsruff checkwith the custom message; the suite is green without it. An exception needs a per-line# noqa: TID251with a reason (relax-with-receipts).Notes: tests still use pytest's
monkeypatch.setenv(not banned — it's the test API, not ad-hoc env reading). Thepydantic-settingsdependency itself lands with the first realSettingsclass (nothing to configure yet).🤖 Generated with Claude Code