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
feat: add support for case insensitive env names #313
feat: add support for case insensitive env names #313
Conversation
I will complete the other TODOs once I know the PR has a good chance of being merged. |
Codecov Report
@@ Coverage Diff @@
## master #313 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 13 13
Lines 1703 1708 +5
Branches 321 323 +2
=====================================
+ Hits 1703 1708 +5 |
Definitely happy to merge once complete. |
@samuelcolvin thanks, ready for review again. |
if env_var: | ||
|
||
env_name_ = env_name.lower() if self.__config__.case_insensitive else env_name | ||
env_val = env_vars.get(env_name_, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I came to the conclusion that env_val
was a better ident name now that we have env_vars
above. env_var
in context of env_vars
sounds like its an item from the list. Buts its not. It is a value from the environ dict while env_vars
is said environ dict.
If you prefer to not touch env_var
ident name, I would suggest using a different name than env_vars
above. Maybe normalized_environ
?
Looks great. Thank you very much. |
Thanks for the amazingly prompt collaboration! 🙏 |
feat: add support for case insensitive env names
Change Summary
BaseSettings
can now be configured to read from os.environ in acase-insensitive way.
Related issue number
Arguably will close #277. Doesn't quite meet the exact idea as proposed there, however it achieves the end goal that motivated #277, I think.
Performance Changes
pydantic cares about performance, if there's any risk performance changed on this PR,
please run
make benchmark-pydantic
before and after the change:Checklist
HISTORY.rst
has been updated#<number>
@whatever