ValidationError.validator is None for a false schema, but annotated as str
Los mantenedores suelen responder en 6 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- Python
- Estrellas
- 5k
- Forks
- 741
- Merge medio
- 4 d 17 h
- PR fusionados (30 d)
- 6
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python-jsonschema/jsonschema
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
python-jsonschema/jsonschema#1610 · 1 comentario ·
Los mantenedores suelen responder en 6 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
python-jsonschema/jsonschema#1588 · 2 comentarios ·
Los mantenedores suelen responder en 6 días
-
Iterator error contexts lose parent links and absolute pathsQuizá libre de nuevo @DawnofGenX la tomó hace 59 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
python-jsonschema/jsonschema#1584 · 3 comentarios ·
Los mantenedores suelen responder en 6 días
-
regex format checker crashes with RecursionError on deeply nested patternsPosiblemente ocupada @DawnofGenX la tomó hace 59 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
python-jsonschema/jsonschema#1538 · 1 comentario ·
Los mantenedores suelen responder en 6 días
-
is_duration raises an uncaught decimal.Overflow on a duration with a large exponentQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoNeeds Test Upstream
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
python-jsonschema/jsonschema#1511 · 1 comentario ·
Los mantenedores suelen responder en 6 días
Todos los issues de python-jsonschema/jsonschema
Issues similares
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
web-push-libs/pywebpush#216 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AgriciDaniel/claude-seo#572 ·
Los mantenedores suelen responder en 5 días
-
area:print-dispatch
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
Los mantenedores suelen responder en 1 día
-
area: docs domain: technical-writing good first issue type: documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
Deepak3699/Ai_Mentor#919 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día