Skip to content

Commit b470aba

Browse files
committed
Fix lint issues. Preexisting tests pass.
1 parent 0a46a39 commit b470aba

15 files changed

+48
-42
lines changed

mypy/checkexpr.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,20 @@ def check_typeddict_call(self, callee: TypedDictType,
198198
kwargs = args[0]
199199
item_name_exprs = [item[0] for item in kwargs.items]
200200
item_args = [item[1] for item in kwargs.items]
201-
201+
202202
item_names = [] # List[str]
203203
for item_name_expr in item_name_exprs:
204204
if not isinstance(item_name_expr, StrExpr):
205205
self.chk.fail(messages.TYPEDDICT_KEY_MUST_BE_STRING_LITERAL, item_name_expr)
206206
return AnyType()
207207
item_names.append(item_name_expr.value)
208-
208+
209209
return self.check_typeddict_call_with_kwargs(
210210
callee, OrderedDict(zip(item_names, item_args)), context)
211211
else:
212212
self.chk.fail(messages.INVALID_TYPEDDICT_ARGS, context)
213213
return AnyType()
214-
214+
215215
def check_typeddict_call_with_kwargs(self, callee: TypedDictType,
216216
kwargs: 'OrderedDict[str, Expression]',
217217
context: Context) -> Type:
@@ -226,20 +226,21 @@ def check_typeddict_call_with_kwargs(self, callee: TypedDictType,
226226
kwargs.keys() - callee.items.keys()),
227227
context)
228228
return AnyType()
229-
229+
230230
items = OrderedDict() # type: OrderedDict[str, Type]
231231
for (item_name, item_expected_type) in callee.items.items():
232232
item_value = kwargs[item_name]
233-
233+
234234
item_actual_type = self.chk.check_simple_assignment(
235235
lvalue_type=item_expected_type, rvalue=item_value, context=item_value,
236236
msg=messages.INCOMPATIBLE_TYPES,
237237
lvalue_name='TypedDict item',
238238
rvalue_name='expression')
239239
items[item_name] = item_actual_type
240-
240+
241241
mapping_value_type = join.join_type_list(list(items.values()))
242-
fallback = self.chk.named_generic_type('typing.Mapping', [self.chk.str_type(), mapping_value_type])
242+
fallback = self.chk.named_generic_type('typing.Mapping',
243+
[self.chk.str_type(), mapping_value_type])
243244
return TypedDictType(items, fallback)
244245

245246
# Types and methods that can be used to infer partial types.

mypy/constraints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def visit_tuple_type(self, template: TupleType) -> List[Constraint]:
341341
return self.infer_against_any(template.items)
342342
else:
343343
return []
344-
344+
345345
def visit_typeddict_type(self, template: TypedDictType) -> List[Constraint]:
346346
actual = self.actual
347347
# TODO: Is it correct to require identical keys here?

mypy/erasetype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from mypy.types import (
44
Type, TypeVisitor, UnboundType, ErrorType, AnyType, Void, NoneTyp, TypeVarId,
5-
Instance, TypeVarType, CallableType, TupleType, TypedDictType, UnionType, Overloaded,
5+
Instance, TypeVarType, CallableType, TupleType, TypedDictType, UnionType, Overloaded,
66
ErasedType, PartialType, DeletedType, TypeTranslator, TypeList, UninhabitedType, TypeType
77
)
88
from mypy import experiments
@@ -77,7 +77,7 @@ def visit_overloaded(self, t: Overloaded) -> Type:
7777

7878
def visit_tuple_type(self, t: TupleType) -> Type:
7979
return t.fallback.accept(self)
80-
80+
8181
def visit_typeddict_type(self, t: TypedDictType) -> Type:
8282
return t.fallback.accept(self)
8383

mypy/expandtype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from mypy.types import (
44
Type, Instance, CallableType, TypeVisitor, UnboundType, ErrorType, AnyType,
5-
Void, NoneTyp, TypeVarType, Overloaded, TupleType, TypedDictType, UnionType,
5+
Void, NoneTyp, TypeVarType, Overloaded, TupleType, TypedDictType, UnionType,
66
ErasedType, TypeList, PartialType, DeletedType, UninhabitedType, TypeType, TypeVarId
77
)
88

@@ -92,7 +92,7 @@ def visit_overloaded(self, t: Overloaded) -> Type:
9292

9393
def visit_tuple_type(self, t: TupleType) -> Type:
9494
return t.copy_modified(items=self.expand_types(t.items))
95-
95+
9696
def visit_typeddict_type(self, t: TypedDictType) -> Type:
9797
return t.copy_modified(item_types=self.expand_types(t.items.values()))
9898

mypy/fixup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def visit_tuple_type(self, tt: TupleType) -> None:
195195
it.accept(self)
196196
if tt.fallback is not None:
197197
tt.fallback.accept(self)
198-
198+
199199
def visit_typeddict_type(self, tdt: TypedDictType) -> None:
200200
if tdt.items:
201201
for it in tdt.items.values():

mypy/indirection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def visit_overloaded(self, t: types.Overloaded) -> Set[str]:
8686

8787
def visit_tuple_type(self, t: types.TupleType) -> Set[str]:
8888
return self._visit(*t.items) | self._visit(t.fallback)
89-
89+
9090
def visit_typeddict_type(self, t: types.TypedDictType) -> Set[str]:
9191
return self._visit(*t.items.values()) | self._visit(t.fallback)
9292

mypy/join.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def visit_tuple_type(self, t: TupleType) -> Type:
240240
return TupleType(items, fallback)
241241
else:
242242
return self.default(self.s)
243-
243+
244244
def visit_typeddict_type(self, t: TypedDictType) -> Type:
245245
if isinstance(self.s, TypedDictType):
246246
items = OrderedDict([

mypy/meet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def visit_tuple_type(self, t: TupleType) -> Type:
246246
return TupleType(items, t.fallback)
247247
else:
248248
return self.default(self.s)
249-
249+
250250
def visit_typeddict_type(self, t: TypedDictType) -> Type:
251251
if isinstance(self.s, TypedDictType):
252252
items = OrderedDict([
@@ -275,7 +275,7 @@ def visit_type_type(self, t: TypeType) -> Type:
275275

276276
def meet(self, s: Type, t: Type) -> Type:
277277
return meet_types(s, t)
278-
278+
279279
def meet_maybe_one(self, s: Optional[Type], t: Optional[Type]) -> Type:
280280
if s is None:
281281
assert t is not None

mypy/messages.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@
7171
KEYWORD_ARGUMENT_REQUIRES_STR_KEY_TYPE = \
7272
'Keyword argument only valid with "str" key type in call to "dict"'
7373
ALL_MUST_BE_SEQ_STR = 'Type of __all__ must be {}, not {}'
74-
INVALID_TYPEDDICT_ARGS = 'Expected keyword arguments or dictionary literal in TypedDict constructor'
75-
TYPEDDICT_KEY_MUST_BE_STRING_LITERAL = 'Expected key in TypedDict constructor to be string literal'
74+
INVALID_TYPEDDICT_ARGS = \
75+
'Expected keyword arguments or dictionary literal in TypedDict constructor'
76+
TYPEDDICT_KEY_MUST_BE_STRING_LITERAL = \
77+
'Expected key in TypedDict constructor to be string literal'
7678

7779

7880
class MessageBuilder:

mypy/nodes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,8 @@ def serialize(self) -> JsonDict:
20362036
'bases': [b.serialize() for b in self.bases],
20372037
'_promote': None if self._promote is None else self._promote.serialize(),
20382038
'tuple_type': None if self.tuple_type is None else self.tuple_type.serialize(),
2039-
'typeddict_type': None if self.typeddict_type is None else self.typeddict_type.serialize(),
2039+
'typeddict_type':
2040+
None if self.typeddict_type is None else self.typeddict_type.serialize(),
20402041
'flags': get_flags(self, TypeInfo.FLAGS),
20412042
}
20422043
return data

0 commit comments

Comments
 (0)