The following code triggers a false positive:
try:
from unittest import mock # python 3
except ImportError:
import mock # python 2
Example:
$ mypy ~/mypy_false_positive.py
mypy_false_positive.py:4: error: Name 'mock' already defined (by an import)
The false positive is tautilogically impossible, since unittest.mock failing to import would trigger the second statement on line 4.
This is a continuation of #1153.
I'm opening a new issue because #1153 has been closed for ~3 years now and I wanted to provide more up-to-date/salient details.
Additional details:
$ mypy --version
mypy 0.720
$ head -n 1 `which mypy`
#!/usr/bin/python3
$ python3 --version
Python 3.7.4
The following code triggers a false positive:
Example:
The false positive is tautilogically impossible, since
unittest.mockfailing to import would trigger the second statement on line 4.This is a continuation of #1153.
I'm opening a new issue because #1153 has been closed for ~3 years now and I wanted to provide more up-to-date/salient details.
Additional details: