Repository navigation
feat(config): unify environment-backed settings across backend (#13) - #35
Open
2022117144 wants to merge 1 commit into
Open
2022117144 wants to merge 1 commit into
2022117144 wants to merge 1 commit into
Conversation
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.
Summary
Closes #13.
Finish wiring the already-present Pydantic
BaseSettingsconfiguration through the actual backend. Previously the primary API still hard-coded its database path and title, discovery and alerts repeated hard-coded database defaults, andapp/config.pyimportedBaseSettingsdirectly frompydantic(which raises on Pydantic v2).Code changes
settings.app_nameandsettings.db_pathin the realapp.mainentry point, and remove the invalidDeviceimport fromapp.models.pydantic.v1.BaseSettings(available under Pydantic 2 and recent Pydantic 1) with a fallback for older v1 installs..env.example,.gitignore(prevents real local secrets, SQLite files and caches from being committed),requirements.txt(also fills a file expected by the existing Dockerfile), anddocs/CONFIGURATION.md..envvs env precedence, API configuration and ARP discovery DB path overrides.Verification
Windows / Python 3.10 / Pydantic 2.13.4, with
python-dotenvinstalled:python -m pytest -q -p no:cacheprovider tests/test_config.py: 6 passed, four existing FastAPIon_eventdeprecation warnings (not introduced by this patch).python -m flake8 app/config.py app/main.py app/autodiscover.py app/alertrules.py tests/test_config.py --select=E9,F63,F7,F82 --show-source: exit 0.git diff --cached --check: exit 0.The upstream CI still uses Python 3.9 although other existing modules use
str | Noneannotations; a separate focused PR #34 already addresses the upstream CI test/tooling configuration. I have not represented this PR's GitHub-hosted checks as passing until they execute.AI-assisted contribution under a human-operated GitHub account. No payout or bounty approval claimed.