Skip to content

Commit

Permalink
Fix some indentation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
msullivan committed Nov 13, 2019
1 parent 2718ca9 commit 4d2674f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
28 changes: 16 additions & 12 deletions misc/proper_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,24 @@ def is_special_target(right: ProperType) -> bool:
if right.type_object().fullname == 'builtins.tuple':
# Used with Union[Type, Tuple[Type, ...]].
return True
if right.type_object().fullname in ('mypy.types.Type',
'mypy.types.ProperType',
'mypy.types.TypeAliasType'):
if right.type_object().fullname in (
'mypy.types.Type',
'mypy.types.ProperType',
'mypy.types.TypeAliasType'
):
# Special case: things like assert isinstance(typ, ProperType) are always OK.
return True
if right.type_object().fullname in ('mypy.types.UnboundType',
'mypy.types.TypeVarType',
'mypy.types.RawExpressionType',
'mypy.types.EllipsisType',
'mypy.types.StarType',
'mypy.types.TypeList',
'mypy.types.CallableArgument',
'mypy.types.PartialType',
'mypy.types.ErasedType'):
if right.type_object().fullname in (
'mypy.types.UnboundType',
'mypy.types.TypeVarType',
'mypy.types.RawExpressionType',
'mypy.types.EllipsisType',
'mypy.types.StarType',
'mypy.types.TypeList',
'mypy.types.CallableArgument',
'mypy.types.PartialType',
'mypy.types.ErasedType'
):
# Special case: these are not valid targets for a type alias and thus safe.
# TODO: introduce a SyntheticType base to simplify this?
return True
Expand Down
6 changes: 4 additions & 2 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4455,8 +4455,10 @@ def builtin_item_type(tp: Type) -> Optional[Type]:
tp = get_proper_type(tp)

if isinstance(tp, Instance):
if tp.type.fullname in ['builtins.list', 'builtins.tuple', 'builtins.dict',
'builtins.set', 'builtins.frozenset']:
if tp.type.fullname in [
'builtins.list', 'builtins.tuple', 'builtins.dict',
'builtins.set', 'builtins.frozenset',
]:
if not tp.args:
# TODO: fix tuple in lib-stub/builtins.pyi (it should be generic).
return None
Expand Down
3 changes: 1 addition & 2 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,8 +1418,7 @@ def format(typ: Type) -> str:
if isinstance(typ, Instance):
itype = typ
# Get the short name of the type.
if itype.type.fullname in ('types.ModuleType',
'_importlib_modulespec.ModuleType'):
if itype.type.fullname in ('types.ModuleType', '_importlib_modulespec.ModuleType'):
# Make some common error messages simpler and tidier.
return 'Module'
if verbosity >= 2 or (fullnames and itype.type.fullname in fullnames):
Expand Down
6 changes: 2 additions & 4 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,8 +1241,7 @@ class Foo(Bar, Generic[T]): ...
if isinstance(base, UnboundType):
sym = self.lookup_qualified(base.name, base)
if sym is not None and sym.node is not None:
if (sym.node.fullname in ('typing.Protocol',
'typing_extensions.Protocol') and
if (sym.node.fullname in ('typing.Protocol', 'typing_extensions.Protocol') and
i not in removed):
# also remove bare 'Protocol' bases
removed.append(i)
Expand Down Expand Up @@ -3071,8 +3070,7 @@ def is_final_type(self, typ: Optional[Type]) -> bool:
sym = self.lookup_qualified(typ.name, typ)
if not sym or not sym.node:
return False
return sym.node.fullname in ('typing.Final',
'typing_extensions.Final')
return sym.node.fullname in ('typing.Final', 'typing_extensions.Final')

def fail_invalid_classvar(self, context: Context) -> None:
self.fail('ClassVar can only be used for assignments in class body', context)
Expand Down

0 comments on commit 4d2674f

Please sign in to comment.