theskumar / theskumar/python-dotenv

Do you plan to call os.path.expandvars?

Open
#459 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.9k
Forks
581
PR merge metrics
No merged PRs in 30d

Description

I request to be able to fill in the environment variable name by calling os.path.environmentvars when setting the value in main.py#L98.

An environment variable name is, for example, %TEMP% (in Windows).

[.env]
LOG_DIR=%TEMP%\log

If possible, it would be nice if it could be called recursively. os.path.expandvars will only expand the environment variable name once.

def expandvarsRecursive(value):.
    expanded = os.path.expandvars(value)
    return value if expanded == value else expandvarsRecursive(expanded)

The reason for this is that if it is called recursively, we don't have to keep track of the same values.

[.env]
PROJECT_HOME=C:\project
LOG_DIR=%PROJECT_HOME%\log
TRACE_LOG_DIR=%LOG_DIR%\trace

Please consider this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/dotenv/main.py around line 98 and trace how values from .env files are expanded. Check how Windows-style variables and recursive references should behave, then verify the LOG_DIR and TRACE_LOG_DIR examples resolve as requested. No linked tests or further maintainer guidance are provided.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.