python / python/mypy

(🎁) Option to not report errors from stub bodies

Abierto
#12,196 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

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

Descripción

test.py:

import foo
foo.foo("")

stubs/foo/init.pyi:

def foo(i: int) -> None:
    1 + ""

mypy test.py

stubs/foo/__init__.pyi:2: error: Unsupported operand types for + ("int" and "str")
test.py:2: error: Argument 1 to "foo" has incompatible type "str"; expected "int"
Found 2 errors in 2 files (checked 1 source file)

In when I'm working with mypy I basically copy-paste the src of libraries into a stubs folder and gradually type them as needed, but it's a pain when I get errors on the bodies of functions like

stubs/x/y/z.pyi error: Call to untyped function "amongus" in typed context  [no-untyped-call]

The bodies of stub functions shouldn't need to be typechecked imo and there should be an option to disable this.

I don't delete the bodies of the functions because that would be a lot of work, and it is kinda convinient that the impl and types are in the same place.

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

Use the test.py and stubs/foo/init.pyi reproducer and run mypy test.py. Trace how diagnostics from stub function bodies are produced, then verify an option suppresses those diagnostics while retaining the call-site argument error.

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

Evaluación

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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.