Customize error messages (e.g. for translations)
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
Comece pela documentação de ValidationError e pelo tratamento de additionalProperties em jsonschema/_validators.py, incluindo seu uso de _utils.find_additional_properties. Revise a issue relacionada #564 e o contexto de erro existente para determinar o escopo de um mecanismo de mensagens configurável. O resultado deve ser um design revisado com uma forma clara de oferecer suporte a mensagens traduzidas e específicas de cada erro sem duplicar a lógica do validador.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Hi,
I would need to translate the error messages and it happens to be more complicated than I expected (or than it could be, I believe).
I started using information on ValidationErrors to define custom messages, but all relevant information for the message is not always readily available. Found this related issue #564 but with not much follow-up so I thought I could ask again.
For instance, for an "additionalProperties" keyword, looking at the code shows that there is some logic that needs to be reimplemented to make message translations (using internal _utils.find_additional_properties to find the offending properties, two different messages depending on whether properties or patternProperties is used etc.).
In addition to the overhead this introduces, I am afraid that it may drift out of sync with the logic in this package in case of improvements, bug fixes, or new draft support etc. or that internal functions may change without backward compatibility.
I am wondering if it would be possible to not hard-code messages, but use templates instead (e.g. Jinja2), that have access to error-specific contextual data (e.g. offending properties for "additionalProperties" errors), and that could be changed for a translation without touching at the logic. This is for instance the approach taken by xeipuuv/gojsonschema.
I think it would be worth a try, and I would be willing to contribute on this with a little help, if you think it is a good idea.
- Linguagem predominante
- Python
- Estrelas
- 5k
- Forks
- 706
- Merge médio
- 18h 28min
- PRs com merge (30d)
- 4
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 65/100
python-jsonschema/jsonschema#1588 · 2 comentários ·
-
Iterator error contexts lose parent links and absolute pathsTalvez livre de novo @DawnofGenX assumiu há 19 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 ·
-
regex format checker crashes with RecursionError on deeply nested patternsTalvez já em andamento @DawnofGenX assumiu há 19 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
python-jsonschema/jsonschema#1538 · 1 comentário ·
-
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 ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
python-jsonschema/jsonschema#1590 · 5 comentários ·
Todas as issues de python-jsonschema/jsonschema
Issues semelhantes
-
Project submission:Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
slavakurilyak/awesome-ai-agents#845 ·
Mantenedores costumam responder em até 1 dia
-
tests: pin that the atomic writers in utils/paths.py stage the temporary file in the target's directoryTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertadifficulty:2 enhancement good first issue
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 92/100
MakazhanAlpamys/Soup#2178 ·
Mantenedores costumam responder em até 1 dia
-
[BUG] dcg.waggr permutation p-values are folded twice, so near-zero scores get the smallest p-valuesAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
scverse/rapids-singlecell#854 ·
Mantenedores costumam responder em até 1 dia
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGLTalvez já em andamento @ninglinLiu assumiu há 1 dia. Abertaarea:frontend backend:slang bug direction:input
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
random_elements(unique=True) on an OrderedDict: ZeroDivisionError once only zero weights remain, AssertionError with use_weighting=FalseTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 13 dias