Open
Description
Bug Report
While working on qutebrowser/qutebrowser#5317 I think I may have found a bug in mypy. The following code looks correct, and runs fine on my machine.
To Reproduce
- Save the following code to file
/tmp/reproducer.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: fenc=utf-8:et:ts=4:sts=4:sw=4:fdm=marker
from typing import Optional, Sequence, Mapping
import collections
class ModuleInfo:
def __init__(
self,
name: str,
version_attributes: Sequence[str],
min_version: Optional[str] = None
):
self.name = name
self._version_attributes = version_attributes
self.min_version = min_version
MODULE_INFO: Mapping[str, ModuleInfo] = collections.OrderedDict([
(name, ModuleInfo(name, *args))
for (name, *args) in
[
('sip', ['SIP_VERSION_STR']),
('colorama', ['VERSION', '__version__']),
('pypeg2', ['__version__']),
('jinja2', ['__version__']),
('pygments', ['__version__']),
('yaml', ['__version__']),
('adblock', ['__version__'], "0.3.2"),
('cssutils', ['__version__']),
('attr', ['__version__']),
('PyQt5.QtWebEngineWidgets', []),
('PyQt5.QtWebEngine', ['PYQT_WEBENGINE_VERSION_STR']),
('PyQt5.QtWebKitWidgets', []),
]
])
- Run
mypy /tmp/reproducer.py
.
Expected Behavior
There should be no type errors.
Actual Behavior
The output of the command in step 2 returns:
reproducer.py:19: error: List comprehension has incompatible type List[Tuple[Sequence[str], ModuleInfo]]; expected List[Tuple[str, ModuleInfo]]
reproducer.py:19: error: Argument 1 to "ModuleInfo" has incompatible type "Sequence[str]"; expected "str"
reproducer.py:19: error: Argument 2 to "ModuleInfo" has incompatible type "*List[Sequence[str]]"; expected "Optional[str]"
Found 3 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used:
mypy 0.790
- Mypy command-line flags:
mypy /tmp/reproducer.py
- Mypy configuration options from
mypy.ini
(and other config files): None, I think - Python version used:
Python 3.8.6
- Operating system and version: Gentoo Linux