Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#1,432 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sohammishra864-wq ci sta già lavorando.

Dal 29/9/2026.

  • #1433 di @sohammishra864-wq — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
Mezza giornata
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

Inizia in codecarbon/cli/cli_utils.py con get_config() e get_api_endpoint(), quindi confronta get_api_endpoint() con write_local_exp_id() come suggerito. Riproduci entrambi i casi usando i comandi nell’issue e verifica che l’assenza di dati [codecarbon] non causi più il crash di show_config e che api_endpoint venga scritto nella sezione corretta senza duplicazioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
1.9k
Fork
331
Merge medio
19h 3m
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mlco2/codecarbon

Tutte le issue di mlco2/codecarbon

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.