Allow overwrite value by None if already defined

Đang mở
#315 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
devops

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
8.9k
Fork
581
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của theskumar/python-dotenv

Tất cả issue của theskumar/python-dotenv

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.