Variable declared without a value suppresses ${VAR:-default} expansion
I maintainer di solito rispondono entro 12 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 85/100
Direzione di ricerca
L’issue indica Variable.resolve() in src/dotenv/variables.py e fornisce una riproduzione minima con dotenv_values(). Leggi prima quel metodo e i test di espansione delle variabili, poi verifica come viene gestito un valore None per ${A} e ${A:-fallback}. Il risultato atteso è che venga usato il valore predefinito per la forma che lo specifica, mentre ${A} continui a espandersi in una stringa vuota.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment
- python-dotenv 1.2.4 (main, commit 4fbc6ff)
- Python 3.14.0 on Windows 11; the code involved is platform independent
Minimal repro
import io
from dotenv import dotenv_values
print(dotenv_values(stream=io.StringIO("A\nB=${A:-fallback}")))
Actual
OrderedDict({'A': None, 'B': ''})
Expected
OrderedDict({'A': None, 'B': 'fallback'})
${A} should still expand to ""; only the defaulted form is affected.
Why this is wrong
The README's "Variable expansion" section lists the resolution order for
dotenv_values() as: value of the variable in the .env file, value in the
environment, default value, then empty string. A key written without a value
(A) is documented earlier as producing None, and load_dotenv is said to
"simply ignore such variables" — that is, the variable is unset, not set to the
empty string. Since the default is only skipped when the variable has a value,
${A:-fallback} should produce fallback here.
This also contradicts the explicit distinction the README draws between FOO
and FOO=: A and A= currently expand identically ("") even though only
A= is the empty string.
The cause is in Variable.resolve() (src/dotenv/variables.py): a name that is
present in the mapping with a None value is converted to "", so the
supplied default is never used.
- Lingua principale
- Python
- Stelle
- 8.9k
- Fork
- 618
- Merge medio
- 12g 6m
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di theskumar/python-dotenv
-
An empty value ignores ${name:-default}Forse già presa @SashaMIT l’ha presa 41 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
theskumar/python-dotenv#715 ·
I maintainer di solito rispondono entro 12 giorni
-
set_key and unset_key don't fsync before replacing the .env fileForse già presa @Imkkey l’ha presa 40 giorni fa. Apertaenhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
theskumar/python-dotenv#713 ·
I maintainer di solito rispondono entro 12 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
theskumar/python-dotenv#693 · 1 commento ·
I maintainer di solito rispondono entro 12 giorni
-
python-dotenv installation without cli masks python-dotenv cliForse già presa @gyanu2507 l’ha presa 80 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
theskumar/python-dotenv#683 · 4 commenti ·
I maintainer di solito rispondono entro 12 giorni
-
Feature Request: Automatically copy `default.env` to `.env`Forse già presa @dradetsky l’ha presa 189 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
theskumar/python-dotenv#644 · 2 commenti ·
I maintainer di solito rispondono entro 12 giorni
Tutte le issue di theskumar/python-dotenv
Issue simili
-
[Bug]: graphify query loads every language extractor just for _file_stem (about 34 ms per call)Forse già presa @rohit-jsfreaky l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Graphify-Labs/graphify#5160 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Minor bug: Main page buttonApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Operations on a list[T] | None var throw when the value is NoneForse già presa @masenf l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
reflex-dev/reflex#7826 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
UKGovernmentBEIS/control-arena#947 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
jasonacox/Powerwall-Dashboard#897 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno