[~] Refactor

This commit is contained in:
Siarhei Siniak 2024-11-10 21:15:20 +03:00
parent c4944ede7f
commit 1eecc616f5
2 changed files with 36 additions and 10 deletions

44
_m.py

@ -62,21 +62,47 @@ def env(
return None
def ruff(args: list[str]) -> None:
def ruff(argv: list[str]) -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
'-i',
dest='paths',
help='specify paths to check',
default=[],
action='append',
)
parser.add_argument(
'-e',
dest='exclude',
help='rules to ignore',
default=[],
action='append',
)
options, args = parser.parse_known_args(argv)
if len(options.paths) == 0:
options.paths.extend([
'.',
'dotfiles/.local/bin/commands',
])
if len(options.exclude) == 0:
options.exclude.extend([
'E731',
'E713',
'E714',
'E703',
])
res = env([
'-m',
'ruff',
'check',
*args,
'--output-format', 'json',
'--ignore', ','.join([
'E731',
'E713',
'E714',
'E703',
]),
'.',
'dotfiles/.local/bin/commands',
'--ignore', ','.join(options.exclude),
*options.paths,
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert not res is None

@ -23,7 +23,7 @@ import tempfile
import time
import traceback
from typing import (Literal, Optional, Iterable, TypedDict, Callable, Any,)
from typing import (Literal, Optional, TypedDict, Callable,)
logger = logging.getLogger(__name__)