theskumar / theskumar/python-dotenv
Consider using bashlex
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 581
- PR merge metrics
- No merged PRs in 30d
Description
Hi.
I've been using .env files for a while, namely to setup variable and load python virtual environments, also with stuff like autoenv.
This means that my .env files have bash code, like if statements, sourcing other scripts, commands, functions.
dotenvs limited reader code just uses a couple regexs that can't handle much more than export statements. And this is something some people might not be expecting.
Suggestion:
- use bashlex to parse the
.envfiles. https://github.com/idank/bashlex - gather variables defined only at the top level
- implement variable substitution (quite easy to implement) e.g.
${VARNAME:-fallback} - recursively source other sourced scripts, e.g.
.envincludes the linesource .envrc.
This would be a reimplementation of the module, so perhaps something for a major release ?
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
The issue proposes replacing dotenv's limited reader with bashlex. Start by locating the existing .env reader and reviewing bashlex's parsing model; done means top-level variables, ${VARNAME:-fallback} substitution, and recursive source handling work for files such as .env sourcing .envrc, with the scope suitable for a major release.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, python
- Domain
- devops, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100