Closed
Description
With Python 3.5 collections.OrderedDict supports reversed()
for views of its keys, items and values. In order for mypy to support this, the stub for collections needs to be updated. As a direct result though, mypy wouldn't detect illegal code for python < 3.5:
from collections import OrderedDict
OD=OrderedDict()
for k in reversed(OD.keys()):
pass
This is a specific instance of a general problem: how do we deal with different typing behaviour from version to version of python? Should the stubs only keep up with the most current version of python? It would actually be better to always use the most version-specific version of a stub (i.e. stubs/3.3/collections.pyi
if using py3.3), or to have the ability to tell mypy to type check against a specific minor version of python.