Support for interleaved errors
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
Direzione di ricerca
Start by reviewing the linked implementation in tests/mypy_helpers.py and its usage in tests/test_plugin.py, then inspect assertion rewriting in tests/init.py. Compare the proposed interleaved-error format with the current test expectations and determine the required plugin behavior and test coverage before deciding whether the approach can be supported.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Here's what I came up with while trying to replicate mypy's own testcases, which interleave the expected errors in the source code like so:
https://github.com/ikonst/pynamodb-mypy/blob/9453404f576c4ead04749d61eb041e10bec13229/tests/test_plugin.py
The implementation is here:
https://github.com/ikonst/pynamodb-mypy/blob/9453404f576c4ead04749d61eb041e10bec13229/tests/mypy_helpers.py
In a failure case, the failed assertion output will look like:
> assert actual == expected
E assert 'from pynamod...ibute "lower"' == 'from pynamodb..._attr.lower()'
E from pynamodb.attributes import UnicodeAttribute
E from pynamodb.models import Model
E
E class MyModel(Model):
E my_attr = UnicodeAttribute(null=True)
E
E reveal_type(MyModel.my_attr) # E: Revealed type is 'pynamodb.attributes._NullableAttribute[pynamodb.attributes.UnicodeAttribute, builtins.str]'
E reveal_type(MyModel().my_attr) # E: Revealed type is 'Union[builtins.str*, None]'
E - MyModel().my_attr.lower() # E: Item "None" of "Optional[str]" has no attribute "lower"
E + MyModel().my_attr.lower()
Of course, this requires assertion rewriting, which would've been done in the pytest plugin normally:
https://github.com/ikonst/pynamodb-mypy/blob/9453404f576c4ead04749d61eb041e10bec13229/tests/__init__.py#L3
There are two advantages of interleaving the errors in the test code:
- changing the test code does not necessitate updating of line numbers
- updating the test code is easier (by diffing the program against the "expected program", i.e. data-driven testing)
Have you considered allowing a similar approach?
- Lingua principale
- Python
- Stelle
- 257
- Fork
- 33
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di realpython/pytest-mypy
-
integration
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
realpython/pytest-mypy#196 · 2 commenti ·
-
realpython/pytest-mypy#190 · 1 commento · 1 assegnatario ·
-
integration
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
realpython/pytest-mypy#160 · 4 commenti ·
-
integration
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
realpython/pytest-mypy#138 · 2 commenti · 2 reazioni ·
-
Expected mypy errors Aperta
realpython/pytest-mypy#105 · 4 commenti · 1 assegnatario ·
Tutte le issue di realpython/pytest-mypy
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anthropics/skills#1811 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
speaches-ai/speaches#678 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
datalayer/mcp-compose#42 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
UKGovernmentBEIS/inspect_evals#2523 ·