Allow overwrite value by None if already defined

未关闭
#315 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 12 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
devops

调研方向

Start at the load_dotenv entry point and trace how a later file is handled when myVar is absent versus explicitly set to an empty value. Compare the two scenarios in the issue, then verify that loading .envA removes the earlier value and returns None when myVar is not defined there.

由索引模型根据 Issue 内容生成。

描述

I have 2 dotenv files:

Scenario1:
/var/www/flask/.envRoot <---- myVar="foo"
and
/home/userA/.envA <----------- myVar="bar"

load_dotenv(dotenv_path='/var/www/flask/.envRoot',override=True)
os.getenv('myVar')   #  foo
load_dotenv(dotenv_path='/home/userA/.envA',override=True)
os.getenv('myVar')   #  bar

Scenario2:
/var/www/flask/.envRoot <---- myVar="foo"
and
/home/userA/.envA <----------- myVar not defined

load_dotenv(dotenv_path='/var/www/flask/.envRoot',override=True)
os.getenv('myVar')   #  foo
load_dotenv(dotenv_path='/home/userA/.envA',override=True)
os.getenv('myVar')   #  foo

Scenario1 work as spected, but Scenario2 should return None if do not exist on .envA because i explicitly indicate the file to look at. But this do not happen if the key exist e.g: myVar=, only if not defined.

主要语言
Python
星标
8.9k
派生
618
平均合并
12 天 6 分钟
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

theskumar/python-dotenv 的其他 Issue

查看 theskumar/python-dotenv 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。