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 22
33## Unreleased
44
5+ - * Action required:* Move existing behaviour under "parse" subcommand.
6+ Invocations of ` mypy-json-report ` should now be replaced with ` mypy-json-report parse ` .
57- Use GA version of Python 3.11 in test matrix.
68
79## 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.
1414Store the output to a file, and commit it to your git repo.
1515
1616```
17- mypy . --strict | mypy-json-report > known-mypy-errors.json
17+ mypy . --strict | mypy-json-report parse > known-mypy-errors.json
1818git add known-mypy-errors.json
1919git commit -m "Add mypy errors lockfile"
2020```
8080
8181 - name : Run mypy
8282 run : |
83- mypy . --strict | mypy-json-report > known-mypy-errors.json
83+ mypy . --strict | mypy-json-report parse > known-mypy-errors.json
8484
8585 - name : Check for mypy changes
8686 run : |
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import argparse
16+ import enum
1517import json
1618import sys
1719from collections import Counter , defaultdict
1820from dataclasses import dataclass
1921from typing import Counter as CounterType , Dict , Iterator
2022
2123
24+ class ErrorCodes (enum .IntEnum ):
25+ DEPRECATED = 1
26+
27+
2228def 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 :
2346 report_errors ()
2447
2548
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+
2654def report_errors () -> None :
2755 errors = parse_errors_report (sys .stdin )
2856 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 =
3939commands_pre =
4040 poetry install
4141commands =
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"
4343 git diff --exit-code known-mypy-errors.json
You can’t perform that action at this time.
0 commit comments