-
Notifications
You must be signed in to change notification settings - Fork 493
Support no value keys #220
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
Conversation
bae4888 to
a84a013
Compare
|
Please note that I removed Python 3.4 on |
bbc2
left a comment
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.
Thank you for this work.
I think it's OK to accept variables without a value but I don't agree with all the changes made in main.py. However, the changes in parser.py look fine.
I'm curious: What functions or classes of this project would Docker-compose use?
src/dotenv/main.py
Outdated
| key = to_env(k) | ||
| value = to_env(v) | ||
| if key and value: | ||
| os.environ[key] = value |
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.
This is quite complicated. What about simplifying this to the following?
if k in os.environ and not override:
continue
if v is not None:
os.environ[to_env(k)] = to_env(v)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.
Great!
That was me juggling with mypy errors and trying to test everything with None 😄
PTAL
src/dotenv/main.py
Outdated
| """ | ||
| ret = os.getenv(name, new_values.get(name, "")) | ||
| return ret | ||
| return ret if ret is not None else name |
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.
ret can't be None here, so I think the if is not None test shouldn't be added. Also, returning name looks incorrect because "" should be the default value.
It seems that Mypy detects an unrelated issue, but in that case I would suggest adding # type: ignore, if necessary, since it's probably a false positive from Mypy.
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.
Same mypy juggling here. I'll just ignore
PTAL
Signed-off-by: ulyssessouza <ulyssessouza@gmail.com>
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
01c197f to
30b0b0f
Compare
You are welcome!
The idea is to use |
OK good to know. |
bbc2
left a comment
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.
Looks good now. Nice rebasing. 👍
|
@bbc2 Any expectations on a release? For now I'm vendoring from my branch, but I cannot merge into |
|
Draft PR on |
Add support for variables with no value
Closes: #219