Cover diagnostic warning retention and reset behavior with tests

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

@glenlouis8 がすでに取り組んでいます。

2026年10月28日 から。

  • #121 @glenlouis8 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
testing

調査の方向性

tests/test_core_semantics.py の diagnostics-primitives セクションと、src/pythonnative/diagnostics.py の警告動作から始めます。既存の dev_mode フィクスチャと pytest のキャプチャヘルパーを使い、本番モードと開発モードにおける保持、スナップショットの分離、クリア、warn_once() の重複排除を網羅します。uv run pytest tests/test_core_semantics.py -q を実行します。要求されたケースが成功し、診断状態が復元され、ランタイムの変更が不要であれば完了です。

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

説明

good first issue

Problem

The warning log in src/pythonnative/diagnostics.py retains the most recent 200 messages, returns a snapshot in oldest-first order, and clears both messages and deduplication keys when clear_warnings() is called.

tests/test_core_semantics.py already tests deduplication for an explicit key and some production-mode behavior, but it doesn't directly cover log eviction, snapshot isolation, or resetting deduplication. These guarantees keep diagnostics useful during long preview sessions and prevent tests from leaking warning state.

Requested change

Extend the existing diagnostics-primitives section of tests/test_core_semantics.py, using its dev_mode fixture and pytest capture helpers. No runtime changes are expected.

Acceptance criteria

  • Record 201 distinct warnings and assert that exactly the newest 200 remain in oldest-first order.
  • Mutating the list returned by get_warnings() doesn't change the internal log.
  • clear_warnings() empties the log and allows a previously used warn_once key to emit again.
  • Repeated warn_once() calls without a key deduplicate by message; different messages remain distinct.
  • In production mode, calling warn_once() doesn't consume its key: after enabling dev mode, the same key can still emit.
  • Tests restore diagnostic state and use no sleeps, threads, or native backends.

Verification

uv run pytest tests/test_core_semantics.py -q
./scripts/check.sh

Suggested commit message

Following CONTRIBUTING.md:

test(diagnostics): cover warning retention and reset behavior

Before starting

Please follow the issue-claiming process: check for an assignee or linked pull request, comment to claim the issue, and wait for a maintainer to assign it before opening a pull request. Contributor setup is in CONTRIBUTING.md.

主要言語
Python
スター
131
フォーク
22
平均マージ
3日 2時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

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

pythonnative/pythonnative のほかの issue

pythonnative/pythonnative の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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