special support for types from importlib.import_module and pkgutil.resolve_name with Literal arguments
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Note: if you are reporting a wrong signature of a function or a class in
the standard library, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues
Please provide more information to help us understand the issue:
- Are you reporting a bug, or opening a feature request? Feature
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
def get_mock_module(v: Literal["mock"] | Literal["unittest.mock"]) -> ...:
return pkgutils.resolve_name(v)
- What is the actual behavior/output? Any
- What is the behavior/output you expect? Module["mock"] | Module["unittest.mock"]
- What are the versions of mypy and Python you are using? git master
Do you see the same issue after installing mypy from Git master? yes - What are the mypy flags you are using? (For example --strict-optional)
--strict
I think https://github.com/python/mypy/issues/5059 was closed because it was opened as a bug rather than a feature request
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
Beginne damit, das Beispiel mit mypy --strict zu reproduzieren, wobei der Fokus auf importlib.import_module und pkgutil.resolve_name liegt, wenn ihnen Literal-Argumente übergeben werden. Verfolge, wie mypy diese Aufrufe derzeit analysiert; abgeschlossen ist die Aufgabe, wenn das Beispiel ohne Fehler als Module["mock"] | Module["unittest.mock"] inferiert wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100