python / python/mypy

special support for types from importlib.import_module and pkgutil.resolve_name with Literal arguments

Ouverte
#9,356 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

feature
Langage dominant
Python
Étoiles
20.6k
Forks
3.3k
Métriques de merge des PR
Métriques de PR en attente

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par reproduire l’exemple avec mypy --strict, en vous concentrant sur importlib.import_module et pkgutil.resolve_name lorsqu’ils reçoivent des arguments Literal. Suivez la manière dont mypy analyse actuellement ces appels ; c’est terminé lorsque l’exemple est inféré comme Module["mock"] | Module["unittest.mock"] sans erreurs.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
devtools
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.