forked from python/mypy
/
outputjson.test
41 lines (32 loc) · 1.11 KB
/
outputjson.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- Test cases for `--output=json`.
-- These cannot be run by the usual unit test runner because of the backslashes
-- in the output, which get normalized to forward slashes by the test suite on
-- Windows.
[case testOutputJsonNoIssues]
# flags: --output=json
def foo() -> None:
pass
foo()
[out]
[case testOutputJsonSimple]
# flags: --output=json
def foo() -> None:
pass
foo(1)
[out]
{"file": "main", "line": 5, "column": 0, "message": "Too many arguments for \"foo\"", "hint": null, "code": "call-arg"}
[case testOutputJsonWithHint]
# flags: --output=json
from typing import Optional, overload
@overload
def foo() -> None: ...
@overload
def foo(x: int) -> None: ...
def foo(x: Optional[int] = None) -> None:
...
foo('42')
def bar() -> None: ...
bar('42')
[out]
{"file": "main", "line": 12, "column": 0, "message": "No overload variant of \"foo\" matches argument type \"str\"", "hint": "Possible overload variants:\n def foo() -> None\n def foo(x: int) -> None", "code": "call-overload"}
{"file": "main", "line": 15, "column": 0, "message": "Too many arguments for \"bar\"", "hint": null, "code": "call-arg"}