Failure to resolve a specific import structure

Aperta
#4,144 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Recreate the package using top/init.py, top/b/init.py, top/b/_b.py, and top/c.py, then run mypy -m top to observe the unresolved b.Cls error. Trace how the import resolver handles the re-export from top.b while top is being initialized. Done means this example resolves b.Cls without the reported error, with relevant tests added or updated.

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

Descrizione

bug priority-2-low topic-import-cycles

Given the following module structure:

top
|-- __init__.py
|-- b
|   |-- __init__.py
|   `-- _b.py
`-- c.py

And the following module contents:

  • top/__init__.py:
from .b import *
from .c import *
  • top/b/__init__.py:
from ._b import *
  • top/b/_b.py:
import top
class Cls:
    pass
  • top/c.py:
from . import b
foo: b.Cls = None

mypy -m top fails to resolve b.Cls:

top/c.py:2: error: Name 'b.Cls' is not defined

Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Merge medio
1g 18h
PR unite (30g)
54

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.