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

Fix variable expansion order with override=False #287

Merged
merged 3 commits into from Dec 5, 2020

Commits on Nov 15, 2020

  1. Copy the full SHA
    ee61cc0 View commit details
    Browse the repository at this point in the history
  2. Decouple variable parsing and expansion

    This is now done in two steps:
    
    - Parse the value into a sequence of atoms (literal of variable).
    - Resolve that sequence into a string.
    bbc2 committed Nov 15, 2020
    Copy the full SHA
    ab50c82 View commit details
    Browse the repository at this point in the history
  3. Fix variable expansion order without override

    This fixes an issue when a variable is resolved differently in two
    bindings.
    
    For instance, take the following env file:
    
    ```
    PORT=8000
    URL=http://localhost:${PORT}
    ```
    
    With `PORT` set to `1234` in the environment, the environment resulting
    from `dotenv_load(override=False)` would be:
    
    ```
    PORT=1234
    URL=http://localhost:8000
    ```
    
    This was inconsistent and is fixed by this commit.  The environment
    would now be:
    
    ```
    PORT=1234
    URL=http://localhost:1234
    ```
    
    with override, and
    
    ```
    PORT=8000
    URL=http://localhost:8000
    ```
    
    without override.
    
    The behavior of `load_dotenv` is unchanged and always assumes
    `override=True`.
    bbc2 committed Nov 15, 2020
    Copy the full SHA
    5a797e0 View commit details
    Browse the repository at this point in the history