I just updated my project to Python 3.7 and I'm seeing this error when I run mypy on the project: error: "Type[datetime]" has no attribute "fromisoformat"
datetime does have a function fromisoformat in Python 3.7, but not in previous versions of Python. Why is mypy reporting this error, and how can I get it to analyze Python 3.7 correctly?
Things I've tried so far:
- Deleting .mypy_cache (which has a suspicious looking subfolder titled
3.6) - Reinstalling mypy with
pip install --upgrade --force-reinstall mypy
To reproduce:
Create a python 3.6 project
install mypy 0.761 (latest) in the project venv
scan the project with mypy (
mypy .)update the project to python 3.7
add a file with this code in it:
from datetime import datetime datetime.fromisoformat('2011-11-04 00:05:23.283')scan the project again (
mypy .) [UPDATE: this actually works fine. It was rerunning my precommit hooks without reinstalling pre-commit on the new Python version venv that was causing the problems.]