datetimes and dates are not substitutable but mypy thinks they are
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
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
I tried that first ;-) https://github.com/python/typeshed/issues/3805
Please provide more information to help us understand the issue:
- Are you reporting a bug, or opening a feature request?
This is a bug in the system overall but probably a feature request in mypy itself.
- 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.
from datetime import date, datetime
if datetime.now() < date.today():
print("that's a surprise!")
- What is the actual behavior/output?
No error!
- What is the behavior/output you expect?
A warning, since at runtime I get TypeError: can't compare datetime.datetime to datetime.date.
- What are the versions of mypy and Python you are using?
0.770, 3.8.2
- 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)
python_version=3.8
incremental=True
follow_imports=normal
warn_redundant_casts=True
warn_unused_ignores=True
strict_optional=True
strict_equality=True
no_implicit_optional=True
disallow_untyped_defs=True
disallow_any_generics=True
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 la comparación datetime/date proporcionada con los flags de mypy indicados y confirma el TypeError en tiempo de ejecución frente a la ausencia de un diagnóstico por parte de mypy. Rastrea el comportamiento de la comprobación de comparaciones para estos tipos de Python; se considera terminado cuando mypy informa de la comparación incompatible sin rechazar incorrectamente las comparaciones válidas entre date.
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
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100