python / python/mypy

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

Abierto
#9,356 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

feature
Lenguaje dominante
Python
Estrellas
20.6k
Forks
3.3k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo el ejemplo con mypy --strict, centrándote en importlib.import_module y pkgutil.resolve_name cuando reciben argumentos Literal. Traza cómo analiza actualmente mypy estas llamadas; se considera terminado cuando el ejemplo se infiere como Module["mock"] | Module["unittest.mock"] sin errores.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
devtools
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.