Mypy signals error with Protocol and __rpow__ method with three arguments
Abierto
Nadie ha tomado este issue todavía.
bug
good-first-issue
topic-protocols
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Okay, this is a head-scratcher. 😕
To Reproduce
# test_case.py
from typing import Protocol, overload, runtime_checkable
@runtime_checkable
class PowableProto(Protocol):
@overload
def __pow__(self, other: "PowableProto") -> "PowableProto":
...
@overload
def __pow__(self, other: "PowableProto", modulo: "PowableProto") -> "PowableProto": # <- fine
...
@overload
def __rpow__(self, other: "PowableProto") -> "PowableProto":
...
@overload
def __rpow__(self, other: "PowableProto", modulo: "PowableProto") -> "PowableProto": # <- this (of all things) breaks
...
@overload
def __rpOw__(self, other: "PowableProto") -> "PowableProto":
...
@overload
def __rpOw__(self, other: "PowableProto", modulo: "PowableProto") -> "PowableProto": # <- fine
...
% mypy --version
mypy 0.910
% mypy --config-file=/dev/null test_case.py
/dev/null: No [mypy] section in config file
test_case.py:15: error: Invalid signature "def (test_case.PowableProto, test_case.PowableProto, test_case.PowableProto) -> test_case.PowableProto"
Found 1 error in 1 file (checked 1 source file)
Expected vs. Actual Behavior
I would expect at least consistent behavior among the overridden methods. This only crops up with __rpow__ for some reason. (I have tested many others.)
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags:
--config-file=/dev/null(i.e., force default configuration) - Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used:
Python 3.9.6(frompython --version) - Operating system and version:
Darwin Kernel Version 19.6.0: Thu May 6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64(fromuname -v)
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.
Línea de trabajo
Comienza ejecutando el comando de mypy proporcionado contra test_case.py y compara cómo se gestionan las sobrecargas de tres argumentos de pow y rpow. Sigue la validación de la firma que produce el error, después haz que el comportamiento sea coherente y verifica que el reproducer ya no informe de una firma no válida.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 55/100