Lint
Lint CLI.
Functions⚓︎
check ⚓︎
check(ctx)
Run ruff as check-only.
Source code in calcipy/tasks/lint.py
@task(default=True)
def check(ctx: Context) -> None:
"""Run ruff as check-only."""
_inner_task(ctx, command='ruff check')
fix ⚓︎
fix(ctx, *, unsafe=False)
Run ruff and apply fixes.
Source code in calcipy/tasks/lint.py
@task(
help={
'unsafe': 'if provided, attempt even fixes considered unsafe',
},
)
def fix(ctx: Context, *, unsafe: bool = False) -> None:
"""Run ruff and apply fixes."""
cli_args = '--fix'
if unsafe:
cli_args += ' --unsafe-fixes'
_inner_task(ctx, command='ruff check', cli_args=cli_args)
pre_commit ⚓︎
pre_commit(ctx, *, no_update=False)
Run prek.
Source code in calcipy/tasks/lint.py
@task(
help={
'no_update': 'Skip updating the prek hooks',
},
)
def pre_commit(ctx: Context, *, no_update: bool = False) -> None:
"""Run prek."""
check_installed(ctx, executable='prek', message=PRE_COMMIT_MESSAGE)
run(ctx, 'prek install')
if not no_update:
run(ctx, 'prek autoupdate')
for stage in PRE_COMMIT_HOOK_STAGES:
run(ctx, f'prek run --all-files --hook-stage {stage}')
watch ⚓︎
watch(ctx)
Run ruff as check-only.
Source code in calcipy/tasks/lint.py
@task()
def watch(ctx: Context) -> None:
"""Run ruff as check-only."""
_inner_task(ctx, command='ruff check', cli_args='--watch')