Highlight differences in complex types
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Start with the issue's Callable example and the current incompatible-assignment diagnostic it shows. Define which typical nested-type differences should be highlighted and how multiple differences or line wrapping should behave; done means the resulting diagnostics make the differing parts clear without relying on the full, nearly identical type strings.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Sometimes it's hard to see why two types are incompatible if they are long and almost the same. Dummy example:
from typing import Callable
from mypy_extensions import Arg
x: Callable[[Arg(int, 'foobar'), Arg(int, 'bir'), Arg(int, 'fubar')], None]
y: Callable[
[Arg(int, 'foobar'), Arg(int, 'blr'), Arg(int, 'fubar')], None]
x = y
This is the error:
t.py:7: error: Incompatible types in assignment (expression has type "Callable[[Arg(int, 'foobar'), Arg(int, 'blr'), Arg(int, 'fubar')], None]", variable has type "Callable[[Arg(int, 'foobar'), Arg(int, 'bir'), Arg(int, 'fubar')], None]")
Here's a potential better message that highlights the difference:
t.py:7: error: Incompatible types in assignment (expression has type "Callable[[Arg(int, 'foobar'), Arg(int, 'blr'), Arg(int, 'fubar')], None]", variable has type "Callable[[Arg(int, 'foobar'), Arg(int, 'bir'), Arg(int, 'fubar')], None]")
t.py:7: note: Expression type: ..., Arg(int, 'blr'), ...
t.py:7: note: Variable type: ..., Arg(int, 'bir'), ...
t.py:7: note: ^^^
It's not clear what's the best way to generalize this sort of "type diff" to arbitrary nested types and to arbitrary type differences. We should at least handle some typical cases. We could also look at how other (non-Python) language implementations handle this.
Just splitting long lines and aligning them would help a bit (but in general the alignment could be off, since there could be multiple differences in types, only some of which are problematic):
t.py:7: error: Incompatible types in assignment (expression has type "Callable[[Arg(int, 'foobar'), Arg(int, 'blr'), Arg(int, 'fubar')], None]",
t.py:7: error: variable has type "Callable[[Arg(int, 'foobar'), Arg(int, 'bir'), Arg(int, 'fubar')], None]")
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 54
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python/mypy
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug topic-configuration topic-error-reporting
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Todos los issues de python/mypy
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
zostera/django-bootstrap4#894 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
use-agent-os/agent-os#3276 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
NousResearch/hermes-agent#117848 ·