mypy RecursionError analyzing pint.facets.plain.quantity.PlainQuantity
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Crash Report
mypy crashes with RecursionError while analyzing pint (since pint==0.26.1). Reproduced with compiled and non-compiled mypy.
Traceback
... skipping approx 50000 lines ...
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 560, in visit_instance
return self.query_types(t.args)
~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in query_types
return any(t.accept(self) for t in types)
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in <genexpr>
return any(t.accept(self) for t in types)
~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/types.py", line 1684, in accept
return visitor.visit_instance(self)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 560, in visit_instance
return self.query_types(t.args)
~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in query_types
return any(t.accept(self) for t in types)
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in <genexpr>
return any(t.accept(self) for t in types)
~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/types.py", line 1684, in accept
return visitor.visit_instance(self)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 560, in visit_instance
return self.query_types(t.args)
~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in query_types
return any(t.accept(self) for t in types)
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in <genexpr>
return any(t.accept(self) for t in types)
~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/types.py", line 1684, in accept
return visitor.visit_instance(self)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
RecursionError: maximum recursion depth exceeded
/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/pint/facets/numpy/quantity.py:63: note: use --pdb to drop into pdb
RecursionError: maximum recursion depth exceeded
To Reproduce
I narrowed down the issue to this single import of pint.facets.plain.quantity.PlainQuantity.
Run mypy on a file with this content:
from pint.facets.plain.quantity import PlainQuantity
Your Environment
Issue appears since version 0.26 of pint when they introduced massive type annotations for PlainQuantity. See https://github.com/hgrecco/pint/pull/2302 and https://github.com/hgrecco/pint/pull/2303
- Mypy version used:
2.3.1and1.9.1 - Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used:
3.13.12 - Operating system and version: Fedora 43 in WSL2
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, den Absturz mit mypy in einer Datei zu reproduzieren, die pint.facets.plain.quantity.PlainQuantity importiert. Verfolge die Rekursion durch die genannten Pfade type_visitor.py und types.py und überprüfe anschließend, dass die Analyse desselben Imports ohne RecursionError abgeschlossen wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 52/100