Cover diagnostic warning retention and reset behavior with tests

Đang mở Phù hợp với người mới
#94 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

@glenlouis8 đang làm issue này rồi.

Từ ngày 28/10/2026.

  • #121 của @glenlouis8 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
testing

Hướng nghiên cứu

Bắt đầu với phần diagnostics-primitives trong tests/test_core_semantics.py và hành vi cảnh báo trong src/pythonnative/diagnostics.py. Dùng fixture dev_mode hiện có và các helper capture của pytest để kiểm tra việc lưu giữ, cô lập snapshot, xóa và khử trùng lặp warn_once() trong chế độ production và dev. Chạy uv run pytest tests/test_core_semantics.py -q; hoàn tất khi các trường hợp được yêu cầu đều đạt, trạng thái chẩn đoán được khôi phục và không cần thay đổi runtime.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
131
Fork
22
Merge trung bình
3 ngày 2 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pythonnative/pythonnative

Tất cả issue của pythonnative/pythonnative

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.