Confusing message for indirect import from a stub

Offen
#4,091 7 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
38/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
devtools

Rechercherichtung

Download testcase.zip and run mypy --config-file=mypy.ini -p testcase to reproduce the reported errors. Start with teststubs/a/stubA.pyi, testcase/init.py, b.init.pyi, and b.stubB, then trace why the indirect import is not recognized. Done means the supplied case no longer reports either missing TestClass error.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

priority-1-normal topic-error-reporting topic-usability

Indirect imports in stubs don't seem to work. I tested the following case against mypy 0.520, where everything worked (no error detected), mypy 0.530 (where the error occurred) and the current git version, which also had the same error as mypy 0.530.

I attached a zip file with the test case:
testcase.zip

The mypy call line is just mypy --config-file=mypy.ini -p testcase.

The error I get is the following:

teststubs/a/stubA.pyi:1: error: Module 'b' has no attribute 'TestClass'
testcase/__init__.py:1: error: Module 'a.stubA' has no attribute 'TestClass'

The main problem is the first line. Module 'b' imports 'TestClass' from b.stubB in b.__init__.pyi, but mypy for some reason does not know that.

Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
Ø Merge
1 T. 18 Std.
Gemergte PRs (30 T.)
54

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python/mypy

Alle Issues in python/mypy

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.