ValidationError.validator is None for a false schema, but annotated as str
Maintainer thường phản hồi trong vòng 6 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Start with the two false-schema branches in jsonschema/validators.py and _Error.__init__ in jsonschema/exceptions.py; compare their runtime behavior with the validator annotation and its documentation. Decide whether None should be allowed or the branches should supply another value, then check the related tests and update them to cover errors from a false schema. Done means runtime behavior, annotations, and documentation agree on the chosen behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
A ValidationError produced by a false (sub)schema has validator=None and validator_value=None:
>>> import jsonschema
>>> e = next(jsonschema.Draft202012Validator({"properties": {"a": False}}).iter_errors({"a": 1}))
>>> e.validator, e.validator_value, e.schema
(None, None, False)
That comes from the two False-schema branches, which pass validator=None
(validators.py#L377,
#L412),
while _Error.__init__ annotates the parameter as validator: str
(exceptions.py#L63),
and the docs describe validator as "the name of the failed keyword". There is no keyword for a boolean schema,
so None is a reasonable value at runtime -- but the annotation does not allow it.
This matters downstream because typeshed's types-jsonschema mirrors the annotation (validator: str | Unset, since
python/typeshed#15353), so type checkers treat error.validator as always a string, and code that relies on that
(e.g. error.validator.upper()) passes type checking and fails on errors from false schemas.
Which side would you consider correct?
- the annotation (and docs) should admit
Nonefor errors raised by a booleanfalseschema, or - the
False-schema branches should pass something else.
Happy to send a PR for whichever you prefer, and to follow up in typeshed accordingly.
Seen on jsonschema 4.25.1 and on main (c497561).
- Ngôn ngữ chính
- Python
- Star
- 5k
- Fork
- 741
- Merge trung bình
- 4 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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 python-jsonschema/jsonschema
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
python-jsonschema/jsonschema#1610 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
python-jsonschema/jsonschema#1588 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Iterator error contexts lose parent links and absolute pathsCó thể làm lại được @DawnofGenX đã nhận 59 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
python-jsonschema/jsonschema#1584 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
regex format checker crashes with RecursionError on deeply nested patternsCó thể đã có người làm @DawnofGenX đã nhận 59 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
python-jsonschema/jsonschema#1538 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
is_duration raises an uncaught decimal.Overflow on a duration with a large exponentCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởNeeds Test Upstream
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
python-jsonschema/jsonschema#1511 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
Tất cả issue của python-jsonschema/jsonschema
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
web-push-libs/pywebpush#216 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AgriciDaniel/claude-seo#572 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
area:print-dispatch
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: docs domain: technical-writing good first issue type: documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Deepak3699/Ai_Mentor#919 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ 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