Semantic analyzer confuses a function with a module
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
The following code creates a package structure that demonstrates what I think is a bug in mypy's new semantic analyzer.
from os import makedirs
makedirs('src/core')
makedirs('src/stuff')
open('src/__init__.py', 'w').write("""
# nothing here
""")
open('src/core/__init__.py', 'w').write("""
from .run import config
""")
open('src/core/run.py', 'w').write("""
from ..stuff import somefunction
config = None
somefunction()
""")
open('src/stuff/__init__.py', 'w').write("""
from .somemore import more
from .somefunction import somefunction
""")
open('src/stuff/somefunction.py', 'w').write("""
def somefunction():
print("Hello, World!")
""")
open('src/stuff/somemore.py', 'w').write("""
def more():
from ..core import config
""")
When checking the created src package with mypy 0.720 and Python 3.7, I get the following error:
src/core/run.py:6: error: Module not callable
What mypy thinks is a module is actually a function. It just has the same name as its containing module.
When I check with --no-new-semantic-analyzer, I do not get this error.
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
Erstelle das generierte src-Paket aus dem Issue-Text erneut und führe mypy 0.720 mit und ohne --no-new-semantic-analyzer aus, wobei du dich auf src/core/run.py und src/stuff/somefunction.py konzentrierst. Verfolge, warum somefunction als Modul statt als aufrufbare Funktion aufgelöst wird; abgeschlossen, wenn der neue semantische Analyzer den Aufruf akzeptiert und das Verhalten durch einen Regressionstest abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100