Skip to content

Commit

Permalink
Support underscore as first char in env file variable names (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
willkg committed Oct 29, 2024
1 parent 787a7ec commit 3e4f15a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
19 changes: 17 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
History
=======

3.4.0 (in development)
----------------------

Backwards incompatible changes:

* Drop support for Python 3.8. Thanks, Rob!

Fixes and features:

* Add support for Python 3.13. (#260) Thanks, Rob!

* Add support for underscore as first character in variable names in env files.
(#263)


3.3.0 (November 6th, 2023)
--------------------------

Backwards incompatible changes:

* Dropped support for Python 3.7. (#220)
* Drop support for Python 3.7. (#220)

Fixes and features:

* Added support for Python 3.12 (#221)
* Add support for Python 3.12 (#221)

* Fix env file parsing in regards to quotes. (#230)

Expand Down
2 changes: 1 addition & 1 deletion src/everett/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@


# Regex for valid keys in an env file
ENV_KEY_RE = re.compile(r"^[a-z][a-z0-9_]*$", flags=re.IGNORECASE)
ENV_KEY_RE = re.compile(r"^[a-z_][a-z0-9_]*$", flags=re.IGNORECASE)

logger = logging.getLogger("everett")

Expand Down
4 changes: 4 additions & 0 deletions tests/data/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ LOGLEVEL=walter
DEBUG=True
YOURE_NOT_A=golfer

# env var with quotes around value
DATABASE_URL="sqlite:///kahlua.db"

# env var that starts with underscore
_TYPER_STANDARD_TRACEBACK=1
2 changes: 2 additions & 0 deletions tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,14 @@ def test_ConfigEnvFileEnv(datadir):
assert cefe.get("not_a", namespace="youre") == "golfer"
assert cefe.get("loglevel") == "walter"
assert cefe.get("LOGLEVEL") == "walter"
assert cefe.get("_typer_standard_traceback") == "1"
assert cefe.get("missing") is NO_VALUE
assert cefe.data == {
"LOGLEVEL": "walter",
"DEBUG": "True",
"YOURE_NOT_A": "golfer",
"DATABASE_URL": "sqlite:///kahlua.db",
"_TYPER_STANDARD_TRACEBACK": "1",
}

cefe = ConfigEnvFileEnv(env_filename)
Expand Down

0 comments on commit 3e4f15a

Please sign in to comment.