Repository: willkg/everett (language: python)

Issue:
support _ as a first character in env file keys
From #224, everett should support `_` as a first character in env file keys. Currently, it does not:

https://github.com/willkg/everett/blob/9b2db32b541b2d18a35a6ae51b9cdc3a5b3f21ba/src/everett/manager.py#L62-L63

References:

https://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html


Discussion / hints:

Fix patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index 2bad241..f0c5648 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -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)
 
diff --git a/src/everett/manager.py b/src/everett/manager.py
index 381c3a1..dac4b48 100644
--- a/src/everett/manager.py
+++ b/src/everett/manager.py
@@ -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")
 


Test patch:
diff --git a/tests/data/.env b/tests/data/.env
index 3704799..795105b 100755
--- a/tests/data/.env
+++ b/tests/data/.env
@@ -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
diff --git a/tests/test_manager.py b/tests/test_manager.py
index f400a22..8f6dd38 100644
--- a/tests/test_manager.py
+++ b/tests/test_manager.py
@@ -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)