Skip to content

Commit 4a541e5

Browse files
author
Guido van Rossum
committed
Revert "Set type of keyword arguments to Dict[unicode, Any] in Python 2. (#1971)"
This reverts commit 51fa569. Sadly this breaks some of our code. :-(
1 parent c29b416 commit 4a541e5

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

mypy/checker.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,8 @@ def is_implicit_any(t: Type) -> bool:
554554
[arg_type])
555555
elif typ.arg_kinds[i] == nodes.ARG_STAR2:
556556
arg_type = self.named_generic_type('builtins.dict',
557-
[self.unicode_type(),
557+
[self.str_type(),
558558
arg_type])
559-
560559
item.arguments[i].variable.type = arg_type
561560

562561
# Type check initialization expressions.
@@ -2116,13 +2115,6 @@ def str_type(self) -> Instance:
21162115
"""Return instance type 'str'."""
21172116
return self.named_type('builtins.str')
21182117

2119-
def unicode_type(self) -> Instance:
2120-
"""Return instance type 'unicode'."""
2121-
if self.options.python_version[0] >= 3:
2122-
return self.named_type('builtins.str')
2123-
else:
2124-
return self.named_type('builtins.unicode')
2125-
21262118
def check_type_equivalency(self, t1: Type, t2: Type, node: Context,
21272119
msg: str = messages.INCOMPATIBLE_TYPES) -> None:
21282120
"""Generate an error if the types are not equivalent. The

test-data/unit/python2eval.test

-19
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,6 @@ print '>', ['a', b'b', u'c']
128128
[out]
129129
> [u'a', 'b', u'c']
130130

131-
[case testUnicodeLiteralsReadKwargs_python2]
132-
from __future__ import unicode_literals
133-
def f(**kwargs): # type: (...) -> None
134-
return kwargs.get('a', '')
135-
f(a='b')
136-
[out]
137-
138-
[case testUnicodeStrReadKwargs_python2]
139-
def f(**kwargs): # type: (...) -> None
140-
return kwargs.get(u'a', '')
141-
f(a='b')
142-
[out]
143-
144-
[case testPy2StrReadKwargs_python2]
145-
def f(**kwargs): # type: (...) -> None
146-
return kwargs.get('a', '')
147-
f(a='b')
148-
[out]
149-
150131
[case testUnicodeLiteralsKwargs_python2]
151132
from __future__ import unicode_literals
152133
def f(**kwargs): # type: (...) -> None

0 commit comments

Comments
 (0)