python / python/mypy

Another circular import in `mypy/test/testreports.py`

Aperta
#17,726 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug topic-developer
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug Report

Running the testreports module in isolation reveals a circular import similar to #15570.

To Reproduce

$ tox r -e py311 -- mypy/test/testreports.py

Expected Behavior

It should collect the tests from the module.

Actual Behavior

______________________________________________________________________________ ERROR collecting mypy/test/testreports.py _______________________________________________________________________________
ImportError while importing test module '~/src/github/python/mypy/mypy/test/testreports.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
mypy/test/testreports.py:7: in <module>
    from mypy.report import CoberturaPackage, get_line_rate
mypy/report.py:19: in <module>
    from mypy import stats
mypy/stats.py:11: in <module>
    from mypy.argmap import map_formals_to_actuals
mypy/argmap.py:8: in <module>
    from mypy.maptype import map_instance_to_supertype
mypy/maptype.py:3: in <module>
    from mypy.expandtype import expand_type_by_instance
mypy/expandtype.py:7: in <module>
    from mypy.types import (
mypy/types.py:3751: in <module>
    from mypy.expandtype import ExpandTypeVisitor
E   ImportError: cannot import name 'ExpandTypeVisitor' from partially initialized module 'mypy.expandtype' (most likely due to a circular import) (~/src/github/python/mypy/mypy/expandtype.py)

Your Environment

  • Mypy version used: master
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: Python 3.11

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.

Direzione di ricerca

Inizia con il comando tox del report e ispeziona la catena di importazione da mypy/test/testreports.py passando per mypy/report.py, mypy/stats.py, mypy/argmap.py, mypy/maptype.py, mypy/expandtype.py e mypy/types.py. Conferma il fallimento dovuto all’importazione circolare, quindi verifica che l’esecuzione del modulo di test raccolga correttamente i suoi test.

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

Valutazione

Stack tecnologico
python
Ambito
devtools
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.