[~] Refactor
This commit is contained in:
parent
c4944ede7f
commit
1eecc616f5
44
_m.py
44
_m.py
@ -62,21 +62,47 @@ def env(
|
|||||||
|
|
||||||
return None
|
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([
|
res = env([
|
||||||
'-m',
|
'-m',
|
||||||
'ruff',
|
'ruff',
|
||||||
'check',
|
'check',
|
||||||
*args,
|
*args,
|
||||||
'--output-format', 'json',
|
'--output-format', 'json',
|
||||||
'--ignore', ','.join([
|
'--ignore', ','.join(options.exclude),
|
||||||
'E731',
|
*options.paths,
|
||||||
'E713',
|
|
||||||
'E714',
|
|
||||||
'E703',
|
|
||||||
]),
|
|
||||||
'.',
|
|
||||||
'dotfiles/.local/bin/commands',
|
|
||||||
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
assert not res is None
|
assert not res is None
|
||||||
|
@ -23,7 +23,7 @@ import tempfile
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from typing import (Literal, Optional, Iterable, TypedDict, Callable, Any,)
|
from typing import (Literal, Optional, TypedDict, Callable,)
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
Loading…
Reference in New Issue
Block a user