python-dotenv
python-dotenv copied to clipboard
set_key creates orphan .env file
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("")
https://github.com/theskumar/python-dotenv/blob/3ffcef60d10813b72ecf85d5941d51b0207cd40e/src/dotenv/main.py#L134