Skip to content
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

Only read env variables on __init__ #157

Merged
merged 2 commits into from
Apr 22, 2024
Merged

Conversation

atwam
Copy link
Contributor

@atwam atwam commented Aug 2, 2023

The default values for arguments to Nomad.__init__ are read when the class is initialized (so when python reads __init__.py.
If one later want to change the values of the NOMAD_* env variables, these new values will get ignored because by then the defaults for arguments are already set.

This changes the commit to have a proper None default, and only read the current values of env variables when __init__() is called.

See https://medium.com/@nebiyuelias1/be-careful-when-using-default-arguments-in-python-fd92df94efee for why defining the default with a function call is prone to error.

@nikita-b nikita-b self-requested a review September 28, 2023 12:33
@nikita-b
Copy link
Collaborator

nikita-b commented Sep 28, 2023

Something happened to CI...I'll check on weekends. @atwam Thanks for contributing!

@nikita-b nikita-b merged commit 35556fa into jrxFive:master Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants