Skip to content

Commit 9910b32

Browse files
committed
feat: support fast lint --no-fix
1 parent 58854b9 commit 9910b32

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

fast_dev_cli/cli.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ def __init__(
10651065
sim: bool = True,
10661066
strict: bool = False,
10671067
ty: bool = False,
1068+
fix: bool = True,
10681069
) -> None:
10691070
self.args = args
10701071
self.check_only = check_only
@@ -1077,6 +1078,7 @@ def __init__(
10771078
self._sim = sim
10781079
self._strict = strict
10791080
self._ty = _ensure_bool(ty)
1081+
self._fix = _ensure_bool(fix)
10801082
super().__init__(_exit, dry)
10811083

10821084
@staticmethod
@@ -1123,11 +1125,13 @@ def to_cmd(
11231125
ruff_check_sim: bool = True,
11241126
mypy_strict: bool = False,
11251127
prefer_ty: bool = False,
1128+
ruff_check_fix: bool = True,
11261129
) -> str:
11271130
if paths != "." and all(i.endswith(".html") for i in paths.split()):
11281131
return f"prettier -w {paths}"
11291132
cmd = ""
1130-
tools = ["ruff format", "ruff check --extend-select=I,B,SIM --fix", "mypy"]
1133+
ruff_check = "ruff check --extend-select=I,B,SIM" + " --fix" * ruff_check_fix
1134+
tools = ["ruff format", ruff_check, "mypy"]
11311135
if check_only:
11321136
tools[0] += " --check"
11331137
if check_only or load_bool("NO_FIX"):
@@ -1256,6 +1260,7 @@ def gen(self) -> str:
12561260
ruff_check_sim=self._sim,
12571261
mypy_strict=self._strict,
12581262
prefer_ty=self._ty,
1263+
ruff_check_fix=self._fix,
12591264
)
12601265

12611266

@@ -1275,6 +1280,7 @@ def lint(
12751280
sim: bool = True,
12761281
strict: bool = False,
12771282
ty: bool = False,
1283+
fix: bool = True,
12781284
) -> None:
12791285
if files is None:
12801286
files = parse_files(sys.argv[1:])
@@ -1292,6 +1298,7 @@ def lint(
12921298
sim=sim,
12931299
strict=strict,
12941300
ty=ty,
1301+
fix=fix,
12951302
).run()
12961303

12971304

@@ -1343,6 +1350,7 @@ def make_style(
13431350
sim: bool = Option(True, help="Whether ruff check with --extend-select=SIM"),
13441351
strict: bool = Option(False, help="Whether run mypy with --strict"),
13451352
ty: bool = Option(False, help="Whether use ty instead of mypy"),
1353+
fix: bool | None = Option(None, help="Whether ruff check with --fix"),
13461354
) -> None:
13471355
"""Run: ruff check/format to reformat code and then mypy to check"""
13481356
if getattr(files, "default", files) is None:
@@ -1352,13 +1360,18 @@ def make_style(
13521360
skip = _ensure_bool(skip_mypy)
13531361
dmypy = _ensure_bool(use_dmypy)
13541362
bandit = _ensure_bool(bandit)
1355-
prefix = _ensure_bool(prefix)
13561363
tool = _ensure_str(tool)
13571364
up = _ensure_bool(up)
13581365
sim = _ensure_bool(sim)
13591366
strict = _ensure_bool(strict)
13601367
kwargs = {"dry": dry, "skip_mypy": skip, "dmypy": dmypy, "bandit": bandit}
1361-
run = check if _ensure_bool(check_only) else functools.partial(lint, prefix=prefix)
1368+
if _ensure_bool(check_only):
1369+
run = check
1370+
else:
1371+
prefix = _ensure_bool(prefix)
1372+
if fix is None or not isinstance(fix, bool):
1373+
fix = load_bool("FASTDEVCLI_FIX", True)
1374+
run = functools.partial(lint, prefix=prefix, fix=fix)
13621375
run(files, tool=tool, up=up, sim=sim, strict=strict, ty=ty, **kwargs)
13631376

13641377

pdm.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)