Inconsistent errors with superclass Liskov violations
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
- Are you reporting a bug, or opening a feature request?
Bug report
class ParentA:
def get_description(self, s: str): ...
class ParentB:
def get_description(self, i: int): ...
# This is a Liskov violation and needs to be ignored.
class ParentViolation(ParentA, ParentB): # type: ignore
...
class ShouldBeIrrelevant:
...
# Inheriting from a violating parent, showing no error
class NoViolation(ParentViolation):
...
# Inheriting from a violating parent, but an extra class makes a violation appear
class SpuriousViolation(ParentViolation, ShouldBeIrrelevant):
...
- What is the actual behavior/output?
The NoViolation class line has no errors.
The SpuriousViolation class line has an error of:
error: Definition of "get_description" in base class "ParentA" is incompatible with definition in base class "ParentB"
- What is the behavior/output you expect?
Either they should both error, or neither should. Personally, I would prefer it if neither errored, since the Liskov violation has already been explicitly ignored by the ParentViolation class. However, I also don't have enough context to know whether this is actually the correct solution.
- What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
mypy 0.720, and verified with mypy 0.730+dev.17a93eac7d1d78e31fc9b347682d86d8d53fe02b
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
Ejecuta el fragmento de Python proporcionado con mypy 0.730+dev y compara los diagnósticos en las líneas de clase NoViolation y SpuriousViolation. Rastrea cómo el checker gestiona la ParentViolation ignorada y las definiciones heredadas de la superclase; el issue estará resuelto cuando ambos casos reciban un tratamiento coherente, con una prueba de regresión que cubra los dos ejemplos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- compilers, devtools
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100