Feature Request: Exception or Warning on Duplicate Configuration Items

オープン
#591 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
devops

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
8.9k
フォーク
581
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

theskumar/python-dotenv のほかの issue

theskumar/python-dotenv の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。