lint: Add black as a linter.

This commit is contained in:
PIG208 2021-05-28 17:06:39 +08:00 committed by Tim Abbott
parent c4edf4bd2f
commit a54cccc012

View file

@ -1,6 +1,7 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
import argparse import argparse
import re
import sys import sys
from zulint.command import LinterConfig, add_default_linter_arguments from zulint.command import LinterConfig, add_default_linter_arguments
@ -44,6 +45,15 @@ def run() -> None:
description="Sorts Python import statements", description="Sorts Python import statements",
check_arg=["--check-only", "--diff"], check_arg=["--check-only", "--diff"],
) )
linter_config.external_linter(
"black",
["black"],
["py"],
description="Reformats Python code",
check_arg=["--check"],
suppress_line=lambda line: line == "All done! ✨ 🍰 ✨\n"
or re.fullmatch(r"\d+ files? would be left unchanged\.\n", line) is not None,
)
@linter_config.lint @linter_config.lint
def custom_py() -> int: def custom_py() -> int: