Skip to content
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

add silent flag to read_dotenv function to suppress UserWarnings https://github.com/jpadilla/django-dotenv/issues/12 #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions dotenv.py
Expand Up @@ -34,7 +34,7 @@
""", re.IGNORECASE | re.VERBOSE)


def read_dotenv(dotenv=None, override=False):
def read_dotenv(dotenv=None, override=False, silent=False):
"""
Read a .env file into os.environ.

Expand All @@ -60,7 +60,7 @@ def read_dotenv(dotenv=None, override=False):
os.environ[k] = v
else:
os.environ.setdefault(k, v)
else:
elif not silent:
warnings.warn("Not reading {0} - it doesn't exist.".format(dotenv),
stacklevel=2)

Expand Down