Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

mypy RecursionError analyzing pint.facets.plain.quantity.PlainQuantity

Aperta
#21,985 3 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
devtools

Direzione di ricerca

Inizia riproducendo il crash con mypy in un file che importa pint.facets.plain.quantity.PlainQuantity. Segui la ricorsione attraverso i percorsi menzionati type_visitor.py e types.py, quindi verifica che l’analisi dello stesso import venga completata senza RecursionError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

crash topic-recursive-types

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.1 and 1.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
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Merge medio
1g 12h
PR unite (30g)
58

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python/mypy

Tutte le issue di python/mypy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.