datetimes and dates are not substitutable but mypy thinks they are · Issue #9015...
source link: https://github.com/python/mypy/issues/9015
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Comments
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 ;-) python/typeshed#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?
- 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
Recommend
-
59
Pendulum Python datetimes made easy. Supports Python 2.7 and 3.4+. >>> import pendulum >>> now_in_paris = pendulum.now('Europe/Paris') >>> now_in_pari...
-
96
GitHub is where people build software. More than 27 million people use GitHub to discover, fork, and contribute to over 80 million projects.
-
6
Exhaustiveness Checking with Mypy Fail at compile time, not at run time Mypy is an optional static type checker for Python. It's been around since 2012 and is gaining tr...
-
4
Applying mypy to real world projects January 2020 Some hints and tips for getting started with Mypy and introducing it to existing projects I think static typing can be ve...
-
14
In Ecto versions 2.1 through 3.x the Ecto.Schema.timestamps/1 feature (updated_at and inserted_at) has been naive_datetime...
-
8
How to save datetimes for future events - (when UTC is not the right answer) Mar 19, 2015 Imagine that it’s January 2015 and you’re making an appointment in a calendar application for a meeting that will take place in Sa...
-
9
Over here python/typing#71 it was discussed to add exception information to stubs, that can be interpreted...
-
10
2020年12月31日2020年12月31日 | by YoungTimes |
-
7
Python Snippet – Datetimes In UTC – Chris West's BlogThere have been so many times when I wanted to have a datetime show in UTC. I am not talking about simply looking at the time and acting as if it is in UTC. For example let’s...
-
8
Introduction to Moment.js Moment.js is the most commonly used JavaScript library to deal with datetimes, however for many use cases today, it may not be the best library to use given the issues of mutability, file si...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK