|
24 | 24 | from mypy.errorcodes import ErrorCode |
25 | 25 | from mypy.errors import ErrorInfo, Errors, ErrorWatcher |
26 | 26 | from mypy.nodes import ( |
27 | | - ARG_NAMED, |
28 | | - ARG_NAMED_OPT, |
29 | | - ARG_OPT, |
30 | 27 | ARG_POS, |
31 | 28 | ARG_STAR, |
32 | 29 | ARG_STAR2, |
|
112 | 109 | "typing.cast", |
113 | 110 | } |
114 | 111 |
|
115 | | - |
116 | | -ARG_CONSTRUCTOR_NAMES: Final = { |
117 | | - ARG_POS: "Arg", |
118 | | - ARG_OPT: "DefaultArg", |
119 | | - ARG_NAMED: "NamedArg", |
120 | | - ARG_NAMED_OPT: "DefaultNamedArg", |
121 | | - ARG_STAR: "VarArg", |
122 | | - ARG_STAR2: "KwArg", |
123 | | -} |
124 | | - |
125 | | - |
126 | 112 | # Map from the full name of a missing definition to the test fixture (under |
127 | 113 | # test-data/unit/fixtures/) that provides the definition. This is used for |
128 | 114 | # generating better error messages when running mypy tests only. |
@@ -2039,6 +2025,7 @@ def report_non_method_protocol( |
2039 | 2025 | def note_call( |
2040 | 2026 | self, subtype: Type, call: Type, context: Context, *, code: ErrorCode | None |
2041 | 2027 | ) -> None: |
| 2028 | + # breakpoint() |
2042 | 2029 | self.note( |
2043 | 2030 | '"{}.__call__" has type {}'.format( |
2044 | 2031 | format_type_bare(subtype, self.options), |
@@ -2487,11 +2474,10 @@ def format_callable_args( |
2487 | 2474 | if arg_kind == ARG_POS and arg_name is None or verbosity == 0 and arg_kind.is_positional(): |
2488 | 2475 | arg_strings.append(format(arg_type)) |
2489 | 2476 | else: |
2490 | | - constructor = ARG_CONSTRUCTOR_NAMES[arg_kind] |
2491 | 2477 | if arg_kind.is_star() or arg_name is None: |
2492 | | - arg_strings.append(f"{constructor}({format(arg_type)})") |
| 2478 | + arg_strings.append(f"{format(arg_type)}") |
2493 | 2479 | else: |
2494 | | - arg_strings.append(f"{constructor}({format(arg_type)}, {repr(arg_name)})") |
| 2480 | + arg_strings.append(f"{arg_name}: {format(arg_type)}") |
2495 | 2481 |
|
2496 | 2482 | return ", ".join(arg_strings) |
2497 | 2483 |
|
@@ -2709,14 +2695,14 @@ def format_literal_value(typ: LiteralType) -> str: |
2709 | 2695 | else: |
2710 | 2696 | return_type = format(func.ret_type) |
2711 | 2697 | if func.is_ellipsis_args: |
2712 | | - return f"Callable[..., {return_type}]" |
| 2698 | + return f"(..., {return_type})" |
2713 | 2699 | param_spec = func.param_spec() |
2714 | 2700 | if param_spec is not None: |
2715 | | - return f"Callable[{format(param_spec)}, {return_type}]" |
| 2701 | + return f"({format(param_spec)}, {return_type})" |
2716 | 2702 | args = format_callable_args( |
2717 | 2703 | func.arg_types, func.arg_kinds, func.arg_names, format, verbosity |
2718 | 2704 | ) |
2719 | | - return f"Callable[[{args}], {return_type}]" |
| 2705 | + return f"({args}) -> {return_type}" |
2720 | 2706 | else: |
2721 | 2707 | # Use a simple representation for function types; proper |
2722 | 2708 | # function types may result in long and difficult-to-read |
|
0 commit comments