set_key states "If the .env path given doesn't exist, fails instead of risking creating an orphan .env somewhere in the filesystem".
set_key has no check if the file exists. As it uses rewrite which if path passed is not a file, it creates an empty file.
if not os.path.isfile(path):
with open(path, mode="w", encoding=encoding) as source:
source.write("")
|
if not os.path.isfile(path): |
set_keystates "If the .env path given doesn't exist, fails instead of risking creating an orphan .env somewhere in the filesystem".set_keyhas no check if the file exists. As it usesrewritewhich if path passed is not a file, it creates an empty file.python-dotenv/src/dotenv/main.py
Line 134 in 3ffcef6