ValidationError.validator is None for a false schema, but annotated as str
Mantenedores costumam responder em até 6 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 48/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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).
- Linguagem predominante
- Python
- Estrelas
- 5k
- Forks
- 741
- Merge médio
- 4d 17h
- PRs com merge (30d)
- 6
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python-jsonschema/jsonschema
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
python-jsonschema/jsonschema#1610 · 1 comentário ·
Mantenedores costumam responder em até 6 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
python-jsonschema/jsonschema#1588 · 2 comentários ·
Mantenedores costumam responder em até 6 dias
-
Iterator error contexts lose parent links and absolute pathsTalvez livre de novo @DawnofGenX assumiu há 59 dias e não há nenhum pull request aberto. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
python-jsonschema/jsonschema#1584 · 3 comentários ·
Mantenedores costumam responder em até 6 dias
-
regex format checker crashes with RecursionError on deeply nested patternsTalvez já em andamento @DawnofGenX assumiu há 59 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
python-jsonschema/jsonschema#1538 · 1 comentário ·
Mantenedores costumam responder em até 6 dias
-
is_duration raises an uncaught decimal.Overflow on a duration with a large exponentTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. AbertaNeeds Test Upstream
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
python-jsonschema/jsonschema#1511 · 1 comentário ·
Mantenedores costumam responder em até 6 dias
Todas as issues de python-jsonschema/jsonschema
Issues semelhantes
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 78/100
web-push-libs/pywebpush#216 · 1 comentário ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
AgriciDaniel/claude-seo#572 ·
Mantenedores costumam responder em até 5 dias
-
area:print-dispatch
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 92/100
Mantenedores costumam responder em até 1 dia
-
area: docs domain: technical-writing good first issue type: documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
Deepak3699/Ai_Mentor#919 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia