theskumar / theskumar/python-dotenv
Feature Request: Unloading function unload_dotenv()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 581
- PR merge metrics
- No merged PRs in 30d
Description
Once load_dotenv() has run, variables are set. To remove them again for unit testing, I need a function, because tests should be independent. I coded this function already, but I think it would be nice to have it included in dotenv. I guess, I'm not the only one with the described problem. But maybe I'm wrong. I stepped over this more than once now. That's why I'm suggesting adding this function:
def unload_dotenv():
"""Remove all dotenv variables from environment."""
dotenv_vars = set(dotenv_values().keys())
for key in dotenv_vars:
os.environ.pop(key, None)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing load_dotenv() and dotenv_values() entry points and their tests. Check how dotenv-loaded variables are identified and verify that the proposed unload_dotenv() behavior is covered, including removing variables without affecting unrelated environment variables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100