File tree Expand file tree Collapse file tree 4 files changed +33
-3
lines changed Expand file tree Collapse file tree 4 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ - * Action required:* Move existing behaviour under "parse" subcommand.
6
+ Invocations of ` mypy-json-report ` should now be replaced with ` mypy-json-report parse ` .
5
7
- Use GA version of Python 3.11 in test matrix.
6
8
7
9
## v0.1.3 [ 2022-09-07]
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Pipe the output of mypy through the `mypy-json-report` CLI app.
14
14
Store the output to a file, and commit it to your git repo.
15
15
16
16
```
17
- mypy . --strict | mypy-json-report > known-mypy-errors.json
17
+ mypy . --strict | mypy-json-report parse > known-mypy-errors.json
18
18
git add known-mypy-errors.json
19
19
git commit -m "Add mypy errors lockfile"
20
20
```
80
80
81
81
- name : Run mypy
82
82
run : |
83
- mypy . --strict | mypy-json-report > known-mypy-errors.json
83
+ mypy . --strict | mypy-json-report parse > known-mypy-errors.json
84
84
85
85
- name : Check for mypy changes
86
86
run : |
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ import argparse
16
+ import enum
15
17
import json
16
18
import sys
17
19
from collections import Counter , defaultdict
18
20
from dataclasses import dataclass
19
21
from typing import Counter as CounterType , Dict , Iterator
20
22
21
23
24
+ class ErrorCodes (enum .IntEnum ):
25
+ DEPRECATED = 1
26
+
27
+
22
28
def main () -> None :
29
+ parser = argparse .ArgumentParser ()
30
+ subparsers = parser .add_subparsers (title = "subcommand" )
31
+
32
+ parser .set_defaults (func = _deprecated_command )
33
+
34
+ parse_parser = subparsers .add_parser (
35
+ "parse" , help = "Transform Mypy output into JSON."
36
+ )
37
+
38
+ parse_parser .set_defaults (func = _parser_command )
39
+
40
+ args = sys .argv [1 :]
41
+ parsed = parser .parse_args (args )
42
+ parsed .func (parsed )
43
+
44
+
45
+ def _parser_command (args : object ) -> None :
23
46
report_errors ()
24
47
25
48
49
+ def _deprecated_command (args : object ) -> None :
50
+ print ("A subcommand is required. Pass --help for usage info." )
51
+ sys .exit (ErrorCodes .DEPRECATED )
52
+
53
+
26
54
def report_errors () -> None :
27
55
errors = parse_errors_report (sys .stdin )
28
56
error_json = json .dumps (errors , sort_keys = True , indent = 2 )
Original file line number Diff line number Diff line change @@ -39,5 +39,5 @@ allowlist_externals =
39
39
commands_pre =
40
40
poetry install
41
41
commands =
42
- poetry run bash -c " mypy . --strict | mypy-json-report > known-mypy-errors.json"
42
+ poetry run bash -c " mypy . --strict | mypy-json-report parse > known-mypy-errors.json"
43
43
git diff --exit-code known-mypy-errors.json
You can’t perform that action at this time.
0 commit comments