Skip to content

**kwargs should be of type Dict[Union[str, unicode], Any] in Python 2 #1954

Closed
@rowillia

Description

@rowillia

If a python 2 file is using from __future__ import unicode_literals breaks reading values out of kwargs using string literals.

Tested using e7ddab1acf44f02d63e8f5d70b1b07c70eeff73b

$ cat > test_kwargs.py << EOL
from __future__ import unicode_literals

def kwargs_func(**kwargs):
  # type: (...) -> str
  return kwargs.get('some_value', '')

kwargs_func(some_value='foo')
EOL

$ mypy --fast-parser --py2 test_kwargs.py
test_kwargs.py: note: In function "kwargs_func":
test_kwargs.py:5: error: Argument 1 to "get" of "dict" has incompatible type "unicode"; expected "str"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions