diff --git a/misc/proper_plugin.py b/misc/proper_plugin.py index 9759c94bcbb9..230f010e90df 100644 --- a/misc/proper_plugin.py +++ b/misc/proper_plugin.py @@ -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 diff --git a/mypy/checker.py b/mypy/checker.py index fb74b93dcb54..2f0d37d626dc 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -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 diff --git a/mypy/messages.py b/mypy/messages.py index 6fe7afedd03a..a8c6882ad43f 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -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): diff --git a/mypy/semanal.py b/mypy/semanal.py index 18adce2a9600..6dd9038231d7 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -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) @@ -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)