Tighten execution_context typing from Any to proper forward reference
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đá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
- 78/100
Hướng nghiên cứu
Đọc mẫu tham chiếu trước hiện có của ExecutionContext trong packages/darnit/src/darnit/sieve/models.py, sau đó cập nhật HandlerContext.execution_context trong packages/darnit/src/darnit/sieve/handler_registry.py. Chạy các bài kiểm tra hiện có và kiểm tra bằng mypy hoặc pyright. Công việc được xem là hoàn tất khi thuộc tính được khai báo kiểu là ExecutionContext | None, .get_or_run_tool() được suy luận kiểu và không phát sinh import vòng tròn khi chạy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Context
#189 added execution_context fields to two dataclasses with loose typing:
packages/darnit/src/darnit/sieve/handler_registry.py:104:
execution_context: Any | None = None
packages/darnit/src/darnit/sieve/models.py:55:
execution_context: Optional["ExecutionContext"] = None # already uses forward ref
The CheckContext side uses a proper "ExecutionContext" forward reference (wrapped in TYPE_CHECKING), but HandlerContext uses Any | None. This means custom handler authors lose type-check assistance when calling handler_ctx.execution_context.get_or_run_tool(...).
Proposal
Change HandlerContext.execution_context to use a proper forward reference matching CheckContext:
if TYPE_CHECKING:
from darnit.core.models import ExecutionContext
@dataclass
class HandlerContext:
...
execution_context: "ExecutionContext | None" = None
Why the loose typing was chosen
Likely to avoid a circular import between sieve/handler_registry.py and core/models.py. TYPE_CHECKING + string annotation is the standard workaround and is already used in sieve/models.py.
Acceptance criteria
HandlerContext.execution_contexttype is tightened toExecutionContext | None- No runtime circular import introduced
mypy/pyrightcan infer.get_or_run_tool()on the attribute- Existing tests still pass
References
- Introduced by: #189
- Related: #194 (wiring first real consumer)
- Ngôn ngữ chính
- Python
- Star
- 22
- Fork
- 27
- Merge trung bình
- 4 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 75
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của darnitdevorg/darnit
-
ci needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
darnitdevorg/darnit#607 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
good first issue maintenance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
darnitdevorg/darnit#587 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Container image has no zizmor, so OSPS-AC-04.02 always reports missing_toolCó thể đã có người làm @mlieberman85 đã nhận 20 ngày trước. Đang mởinfrastructure module-baseline
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
darnitdevorg/darnit#585 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
module-baseline
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
darnitdevorg/darnit#344 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
documentation module-core
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
darnitdevorg/darnit#196 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của darnitdevorg/darnit
Issue tương tự
-
docs size:S
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
strawberry-graphql/strawberry#4794 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dataforgoodfr/cetolog#21 ·
-
security_citations_test fails against ecc 2026.11.6: SECURITY.md quotes ecc v2026.11.2's linesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
btclib-org/btclib#2932 ·
Maintainer thường phản hồi trong vòng 1 ngày