Skip to content

Bad typing for Python 2.7 with unicode_literals #5098

Closed
@ikonst

Description

@ikonst

Consider:

from __future__ import unicode_literals
import sys

print(sys.modules['sys'])

mypy --py2 unicode_literals.py results in:

unicode_literals.py:4: error: Invalid index type "unicode" for "Dict[str, Any]"; expected type "str"

However, python2.7 unicode_literals.py results in:

<module 'sys' (built-in)>

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions