Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

CLI: get_config() returns None without [codecarbon] section; get_api_endpoint() appends api_endpoint under wrong section

オープン 初心者向け
#1,432 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@sohammishra864-wq がすでに取り組んでいます。

2026年9月29日 から。

  • #1433 @sohammishra864-wq による — オープン

評価

難易度
2/5
見積もり時間
半日
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
cli

調査の方向性

codecarbon/cli/cli_utils.py の get_config() と get_api_endpoint() から始め、提案されているとおり get_api_endpoint() と write_local_exp_id() を比較します。issue に記載されているコマンドを使って両方のケースを再現し、[codecarbon] データがない場合でも show_config がクラッシュしなくなっていること、および api_endpoint が重複せず正しいセクションに書き込まれることを確認します。

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

説明

Bug 1 — get_config() returns None
If .codecarbon.config exists but has no [codecarbon] section, get_config() implicitly returns None. show_config() then crashes with TypeError: argument of type 'NoneType' is not iterable on "organization_id" not in d.

Repro:

printf "[other]\nkey=value\n" > .codecarbon.config
codecarbon config   # or show_config path

Bug 2 — get_api_endpoint() writes to the wrong section
When api_endpoint is missing, the function raw-appends api_endpoint=... to the end of the file. If [codecarbon] isn't the last section, the key ends up under another section, and the next call appends it again.

Repro:

printf "[codecarbon]\nproject_id=abc\n\n[other]\nkey=value\n" > .codecarbon.config
python -c "from pathlib import Path; from codecarbon.cli.cli_utils import get_api_endpoint; get_api_endpoint(Path('.codecarbon.config'))"
cat .codecarbon.config   # api_endpoint is under [other]

Proposed fix: return {} from get_config(), and set the key through ConfigParser in get_api_endpoint(), as write_local_exp_id() does. I'm happy to open a PR.

主要言語
Python
スター
1.9k
フォーク
335
平均マージ
16時間 47分
マージ済み PR(30日)
11

環境構築

はじめの一歩

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

mlco2/codecarbon のほかの issue

mlco2/codecarbon の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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