Skip to content

Bad typing for Python 2.7 with unicode_literals #5098

Closed

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)>

Activity

  1. gvanrossum commented on May 23, 2018

    @gvanrossum
    Member
  2. Michael0x2a commented on May 23, 2018

    @Michael0x2a
    Collaborator

    I believe mypy currently doesn't support unicode_literals: there's some related discussion here and here.

    Maybe there's an opportunity to do some usability enhancement here? If we're not planning on supporting unicode_literals any time soon, maybe we can have mypy report a warning when it detects some code using it/link to something in the docs.

  3. gvanrossum commented on May 23, 2018

    @gvanrossum
    Member
  4. ilevkivskyi commented on Dec 30, 2018

    @ilevkivskyi
    Member

    This is essentially a duplicate of #2536, so I am closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions