|
16 | 16 | import re |
17 | 17 | from contextlib import contextmanager |
18 | 18 | from textwrap import dedent |
19 | | -from typing import (Any, Callable, Collection, Final, Iterable, Iterator, List, |
20 | | - Sequence, cast) |
| 19 | +from typing import Any, Callable, Collection, Final, Iterable, Iterator, List, Sequence, cast |
21 | 20 |
|
22 | 21 | import mypy.typeops |
23 | | -from mypy import errorcodes as codes |
24 | | -from mypy import message_registry |
| 22 | +from mypy import errorcodes as codes, message_registry |
25 | 23 | from mypy.erasetype import erase_type |
26 | 24 | from mypy.errorcodes import ErrorCode |
27 | 25 | from mypy.errors import ErrorInfo, Errors, ErrorWatcher |
28 | | -from mypy.nodes import (ARG_NAMED, ARG_NAMED_OPT, ARG_OPT, ARG_POS, ARG_STAR, |
29 | | - ARG_STAR2, CONTRAVARIANT, COVARIANT, |
30 | | - SYMBOL_FUNCBASE_TYPES, ArgKind, CallExpr, ClassDef, |
31 | | - Context, Expression, FuncDef, IndexExpr, MypyFile, |
32 | | - NameExpr, ReturnStmt, StrExpr, SymbolNode, SymbolTable, |
33 | | - TypeInfo, Var, reverse_builtin_aliases) |
| 26 | +from mypy.nodes import ( |
| 27 | + ARG_NAMED, |
| 28 | + ARG_NAMED_OPT, |
| 29 | + ARG_OPT, |
| 30 | + ARG_POS, |
| 31 | + ARG_STAR, |
| 32 | + ARG_STAR2, |
| 33 | + CONTRAVARIANT, |
| 34 | + COVARIANT, |
| 35 | + SYMBOL_FUNCBASE_TYPES, |
| 36 | + ArgKind, |
| 37 | + CallExpr, |
| 38 | + ClassDef, |
| 39 | + Context, |
| 40 | + Expression, |
| 41 | + FuncDef, |
| 42 | + IndexExpr, |
| 43 | + MypyFile, |
| 44 | + NameExpr, |
| 45 | + ReturnStmt, |
| 46 | + StrExpr, |
| 47 | + SymbolNode, |
| 48 | + SymbolTable, |
| 49 | + TypeInfo, |
| 50 | + Var, |
| 51 | + reverse_builtin_aliases, |
| 52 | +) |
34 | 53 | from mypy.operators import op_methods, op_methods_to_symbols |
35 | 54 | from mypy.options import Options |
36 | | -from mypy.subtypes import (IS_CLASS_OR_STATIC, IS_CLASSVAR, IS_SETTABLE, |
37 | | - IS_VAR, find_member, get_member_flags, is_same_type, |
38 | | - is_subtype) |
| 55 | +from mypy.subtypes import ( |
| 56 | + IS_CLASS_OR_STATIC, |
| 57 | + IS_CLASSVAR, |
| 58 | + IS_SETTABLE, |
| 59 | + IS_VAR, |
| 60 | + find_member, |
| 61 | + get_member_flags, |
| 62 | + is_same_type, |
| 63 | + is_subtype, |
| 64 | +) |
39 | 65 | from mypy.typeops import separate_union_literals |
40 | | -from mypy.types import (AnyType, CallableType, DeletedType, FunctionLike, |
41 | | - Instance, LiteralType, NoneType, Overloaded, |
42 | | - Parameters, ParamSpecType, PartialType, ProperType, |
43 | | - TupleType, Type, TypeAliasType, TypedDictType, |
44 | | - TypeOfAny, TypeStrVisitor, TypeType, TypeVarLikeType, |
45 | | - TypeVarTupleType, TypeVarType, UnboundType, |
46 | | - UninhabitedType, UnionType, UnpackType, |
47 | | - flatten_nested_unions, get_proper_type, |
48 | | - get_proper_types) |
| 66 | +from mypy.types import ( |
| 67 | + AnyType, |
| 68 | + CallableType, |
| 69 | + DeletedType, |
| 70 | + FunctionLike, |
| 71 | + Instance, |
| 72 | + LiteralType, |
| 73 | + NoneType, |
| 74 | + Overloaded, |
| 75 | + Parameters, |
| 76 | + ParamSpecType, |
| 77 | + PartialType, |
| 78 | + ProperType, |
| 79 | + TupleType, |
| 80 | + Type, |
| 81 | + TypeAliasType, |
| 82 | + TypedDictType, |
| 83 | + TypeOfAny, |
| 84 | + TypeStrVisitor, |
| 85 | + TypeType, |
| 86 | + TypeVarLikeType, |
| 87 | + TypeVarTupleType, |
| 88 | + TypeVarType, |
| 89 | + UnboundType, |
| 90 | + UninhabitedType, |
| 91 | + UnionType, |
| 92 | + UnpackType, |
| 93 | + flatten_nested_unions, |
| 94 | + get_proper_type, |
| 95 | + get_proper_types, |
| 96 | +) |
49 | 97 | from mypy.typetraverser import TypeTraverserVisitor |
50 | 98 | from mypy.util import plural_s, unmangle |
51 | 99 |
|
@@ -1990,9 +2038,14 @@ def report_non_method_protocol( |
1990 | 2038 | def note_call( |
1991 | 2039 | self, subtype: Type, call: Type, context: Context, *, code: ErrorCode | None |
1992 | 2040 | ) -> None: |
1993 | | - self.note('"{}.__call__" has type {}'.format( |
1994 | | - format_type_bare(subtype, self.options), format_type(call, self.options, verbosity=1) |
1995 | | - ),context, code=code) |
| 2041 | + self.note( |
| 2042 | + '"{}.__call__" has type {}'.format( |
| 2043 | + format_type_bare(subtype, self.options), |
| 2044 | + format_type(call, self.options, verbosity=1), |
| 2045 | + ), |
| 2046 | + context, |
| 2047 | + code=code, |
| 2048 | + ) |
1996 | 2049 |
|
1997 | 2050 | def unreachable_statement(self, context: Context) -> None: |
1998 | 2051 | self.fail("Statement is unreachable", context, code=codes.UNREACHABLE) |
@@ -2104,14 +2157,10 @@ def report_protocol_problems( |
2104 | 2157 | if subtype.extra_attrs and subtype.extra_attrs.mod_name: |
2105 | 2158 | is_module = True |
2106 | 2159 |
|
2107 | | - #show signature of call for supertype |
2108 | | - call = find_member("__call__",supertype,supertype) |
| 2160 | + # show signature of call for supertype |
| 2161 | + call = find_member("__call__", supertype, supertype) |
2109 | 2162 | if call: |
2110 | | - self.note_call( |
2111 | | - supertype,call,context,code=code |
2112 | | - ) |
2113 | | - |
2114 | | - |
| 2163 | + self.note_call(supertype, call, context, code=code) |
2115 | 2164 |
|
2116 | 2165 | # Report missing members |
2117 | 2166 | missing = get_missing_protocol_members(subtype, supertype, skip=skip) |
|
0 commit comments