theskumar / theskumar/python-dotenv
Feature Request: Exception or Warning on Duplicate Configuration Items
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 8.9k
- Fork
- 581
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Currently, py-dotenv uses a strategy of overwriting with the latter value when handling configuration items with the same key, that is, using the last value of the repeated key. However, I just wasted an entire morning because there were three configuration items with the same key in my .env file. 😢
To avoid others encountering similar issues, I propose adding an optional behavior parameter. The default should be warning, meaning the latter value overwrites the former but with a warning. It could also be set to strict, which throws an exception, or to latter-covers, which means the latter value overwrites the former without any warning.
I have researched how other libraries handle this issue, for reference:
| Parser | Duplicate Handling | Notes |
|---|---|---|
| Node.js dotenv | Latter covers | Most common mode |
| Python dotenv | Latter covers | Configurable to override system variables |
| PHP phpdotenv | Default error | Can be set to allow overrides |
| Ruby dotenv | Latter covers | Issues a warning |
| Go godotenv | Latter covers | No warning |
| Docker Compose | Latter covers | Follows file loading order |
Append: maybe a Callable[[list[str]], str] like sum is also acceptable, for #374 suggests a customed merge logic.
Guida per i contributori
Apri 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.
Direzione di ricerca
Start by tracing how py-dotenv handles repeated keys while loading a .env file and review the proposed behavior options. Done should be defined by an agreed API and semantics for warning, strict, latter-covers, and any custom merge logic.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devops
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100