Skip to content

Commit

Permalink
fix: remove autopep8
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKing committed Jun 7, 2024
1 parent 41b99ed commit ae1cbe9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
31 changes: 14 additions & 17 deletions calcipy/tasks/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ def check(ctx: Context) -> None:


@task()
def autopep8(ctx: Context) -> None:
"""Run autopep8.
FYI: This is temporary until ruff implements white space rules
https://github.com/charliermarsh/ruff/issues/970
"""
cli_args = '--aggressive --recursive --in-place --max-line-length=120'
_inner_task(ctx, command='autopep8', cli_args=cli_args)


@task(pre=[autopep8])
def fix(ctx: Context) -> None:
"""Run ruff and apply fixes."""
_inner_task(ctx, command='ruff check', cli_args='--fix')
Expand All @@ -81,6 +69,19 @@ def pylint(ctx: Context, *, report: bool = False) -> None:
# ==============================================================================
# Pre-Commit

ALL_PRE_COMMIT_HOOK_STAGES = [
'commit',
'merge-commit',
'push',
'prepare-commit-msg',
'commit-msg',
'post-checkout',
'post-commit',
'post-merge',
'post-rewrite',
'manual',
]


@task(
help={
Expand All @@ -95,9 +96,5 @@ def pre_commit(ctx: Context, *, no_update: bool = False) -> None:
if not no_update:
run(ctx, 'pre-commit autoupdate')

all_hook_stages = [
'commit', 'merge-commit', 'push', 'prepare-commit-msg', 'commit-msg', 'post-checkout',
'post-commit', 'post-merge', 'post-rewrite', 'manual',
]
stages_cli = ' '.join(f'--hook-stage {stg}' for stg in all_hook_stages)
stages_cli = ' '.join(f'--hook-stage {stg}' for stg in ALL_PRE_COMMIT_HOOK_STAGES)
run(ctx, f'pre-commit run --all-files {stages_cli}')
10 changes: 2 additions & 8 deletions tests/tasks/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,21 @@
import pytest

from calcipy.tasks.executable_utils import python_m
from calcipy.tasks.lint import autopep8, check, fix, pre_commit, pylint, watch
from calcipy.tasks.lint import ALL_PRE_COMMIT_HOOK_STAGES, check, fix, pre_commit, pylint, watch


@pytest.mark.parametrize(
('task', 'kwargs', 'commands'),
[
(check, {}, [f'{python_m()} ruff check ./calcipy ./tests']),
(autopep8, {}, [
f'{python_m()} autopep8 ./calcipy ./tests --aggressive --recursive --in-place --max-line-length=120',
]),
(fix, {}, [f'{python_m()} ruff check ./calcipy ./tests --fix']),
(watch, {}, [f'{python_m()} ruff check ./calcipy ./tests --watch --show-source']),
(pylint, {}, [f'{python_m()} pylint ./calcipy ./tests']),
(pre_commit, {}, [
call('which pre-commit', warn=True, hide=True),
'pre-commit install',
'pre-commit autoupdate',
'pre-commit run --all-files ' + ' '.join(f'--hook-stage {stg}' for stg in (
'commit', 'merge-commit', 'push', 'prepare-commit-msg', 'commit-msg', 'post-checkout',
'post-commit', 'post-merge', 'post-rewrite', 'manual',
)),
'pre-commit run --all-files ' + ' '.join(f'--hook-stage {stg}' for stg in ALL_PRE_COMMIT_HOOK_STAGES),
]),
],
)
Expand Down

0 comments on commit ae1cbe9

Please sign in to comment.