Skip to content

Commit 40b5aed

Browse files
committed
fix code style to mypy guidelines
1 parent a9d0996 commit 40b5aed

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

mypy/nodes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ def get_column(self) -> int:
137137
} # type: Final
138138

139139
_nongen_builtins = {'builtins.tuple': 'typing.Tuple',
140-
'builtins.enumerate': ''} # type: Final
140+
'builtins.enumerate': ''} # type: Final
141141
_nongen_builtins.update((name, alias) for alias, name in type_aliases.items())
142142

143-
def get_nongen_builtins(python_version):
143+
144+
def get_nongen_builtins(python_version: Tuple[int, int]) -> Dict[str, str]:
144145
# After 3.9 with pep585 generic builtins are allowed.
145146
return _nongen_builtins if python_version < (3, 9) else {}
146147

148+
147149
RUNTIME_PROTOCOL_DECOS = ('typing.runtime_checkable',
148150
'typing_extensions.runtime',
149151
'typing_extensions.runtime_checkable') # type: Final

mypy/typeanal.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ def try_analyze_special_unbound_type(self, t: UnboundType, fullname: str) -> Opt
345345

346346
def get_omitted_any(self, typ: Type, fullname: Optional[str] = None) -> AnyType:
347347
disallow_any = not self.is_typeshed_stub and self.options.disallow_any_generics
348-
return get_omitted_any(disallow_any, self.fail, self.note, typ, self.options.python_version, fullname)
348+
return get_omitted_any(disallow_any, self.fail, self.note, typ,
349+
self.options.python_version, fullname)
349350

350351
def analyze_type_with_type_info(
351352
self, info: TypeInfo, args: Sequence[Type], ctx: Context) -> Type:
@@ -1028,7 +1029,8 @@ def fix_instance(t: Instance, fail: MsgCallback, note: MsgCallback,
10281029
fullname = None # type: Optional[str]
10291030
else:
10301031
fullname = t.type.fullname
1031-
any_type = get_omitted_any(disallow_any, fail, note, t, python_version, fullname, unexpanded_type)
1032+
any_type = get_omitted_any(disallow_any, fail, note, t, python_version, fullname,
1033+
unexpanded_type)
10321034
t.args = (any_type,) * len(t.type.type_vars)
10331035
return
10341036
# Invalid number of type parameters.
@@ -1287,7 +1289,8 @@ def make_optional_type(t: Type) -> Type:
12871289
return UnionType([t, NoneType()], t.line, t.column)
12881290

12891291

1290-
def fix_instance_types(t: Type, fail: MsgCallback, note: MsgCallback, python_version: Tuple[int, int]) -> None:
1292+
def fix_instance_types(t: Type, fail: MsgCallback, note: MsgCallback,
1293+
python_version: Tuple[int, int]) -> None:
12911294
"""Recursively fix all instance types (type argument count) in a given type.
12921295
12931296
For example 'Union[Dict, List[str, int]]' will be transformed into
@@ -1297,12 +1300,15 @@ def fix_instance_types(t: Type, fail: MsgCallback, note: MsgCallback, python_ver
12971300

12981301

12991302
class InstanceFixer(TypeTraverserVisitor):
1300-
def __init__(self, fail: MsgCallback, note: MsgCallback, python_version: Tuple[int, int]) -> None:
1303+
def __init__(
1304+
self, fail: MsgCallback, note: MsgCallback, python_version: Tuple[int, int]
1305+
) -> None:
13011306
self.fail = fail
13021307
self.note = note
13031308
self.python_version = python_version
13041309

13051310
def visit_instance(self, typ: Instance) -> None:
13061311
super().visit_instance(typ)
13071312
if len(typ.args) != len(typ.type.type_vars):
1308-
fix_instance(typ, self.fail, self.note, disallow_any=False, python_version=self.python_version, use_generic_error=True)
1313+
fix_instance(typ, self.fail, self.note, disallow_any=False,
1314+
python_version=self.python_version, use_generic_error=True)

0 commit comments

Comments
 (0)