Skip to content

Add settings #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 2, 2025
Merged

Add settings #214

merged 6 commits into from
May 2, 2025

Conversation

pombredanne
Copy link
Member

This PR builds on @heliocastro PR:

This is a draft. It should be split in something else for the CHANGELOG and for the tests.

heliocastro and others added 4 commits April 4, 2025 10:50
Settings can now be defined through environment variables, .env local
file or regular arguments to the script.

All variables need to be prefixed by PYTHON_INSPECTOR_ to be recognized.
Example: PYTHON_INSPECTOR_INDEX_URL="https://pypy1.org,https://foo.bar"
will add this two repositories overriding the public repository.

Raise the minimum python version to 3.9 as 3.8 is EOL.

Adapt base code to use new settings class

Adapt tests to use new settings class

Signed-off-by: Helio Chissini de Castro <[email protected]>
* Do not hide settings module imports with settings variable
* Update requirements for pydantic and pydantic_settings
* Restore tests on Python 3.8
* Regenerate tests expectations
* Remove code formatting changes and minor typing changes
* Improve support for defaults and index_urls

Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
This was removed implicitly when adding a default OS to the CLI.

Signed-off-by: Philippe Ombredanne <[email protected]>
@pombredanne pombredanne marked this pull request as draft April 6, 2025 20:26
@pombredanne
Copy link
Member Author

In the meantime, I found out that click (the library which is used here for the command line processing) has built-in support for environment variables, and that it is trivial to add support for .env files with the https://github.com/theskumar/python-dotenv library which is also used in Flask (where click started).

So I am wondering if using the built-in click support would not be better than using pydantic and also limit the number of deps.

Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
@pombredanne pombredanne marked this pull request as ready for review May 2, 2025 17:18
@pombredanne
Copy link
Member Author

The tests all pass. The only pending issue is the Ci for doc, and it will solved elsewhere. Merging.

@pombredanne pombredanne merged commit eb15ffa into main May 2, 2025
8 of 10 checks passed
@pombredanne pombredanne deleted the add-settings branch May 2, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants