Skip to content

Commit

Permalink
added pre-commit hook
Browse files Browse the repository at this point in the history
and new hook argument for visiumlint
  • Loading branch information
Pascal Epple committed Oct 13, 2023
1 parent 2eda02f commit 00ec6e0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- id: visiumlint
name: visiumlint
description: Run visiumlint without Pylint
entry: visiumlint --hook
language: python
pass_filenames: false
35 changes: 19 additions & 16 deletions src/visiumlint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import typer


def lint(check_lint: bool = typer.Option(False, "--check", help="Enable check mode.")) -> None:
def lint(check_lint: bool = typer.Option(False, "--check", help="Enable check mode."), hook : bool = typer.Option(False, "--hook", help="Enable hook mode.")) -> None:
"""Implement the logic of the lint command."""
if check_lint:
check_lint = "--check"
Expand All @@ -21,21 +21,24 @@ def lint(check_lint: bool = typer.Option(False, "--check", help="Enable check mo
["sh", "-c", f"isort {check_lint} --gitignore . --line-length 120 --profile black"], check=False
).returncode

run(["sh", "-c", "echo Running pylint"], check=False)
pylint_returncode = run(
[
"sh",
"-c",
"pylint . --recursive=y --load-plugins=pylint.extensions.docstyle,pylint.extensions.docparams --disable=fixme,too-few-public-methods",
"--variable-rgx",
"^[a-z][a-z0-9_]*$",
"--argument-rgx",
"^[a-z][a-z0-9_]*$",
"--max-line-length",
"120",
],
check=False,
).returncode
if not hook:
run(["sh", "-c", "echo Running pylint"], check=False)
pylint_returncode = run(
[
"sh",
"-c",
"pylint . --recursive=y --load-plugins=pylint.extensions.docstyle,pylint.extensions.docparams --disable=fixme,too-few-public-methods",
"--variable-rgx",
"^[a-z][a-z0-9_]*$",
"--argument-rgx",
"^[a-z][a-z0-9_]*$",
"--max-line-length",
"120",
],
check=False,
).returncode
else:
pylint_returncode = 0

run(["sh", "-c", "echo Running pydocstyle"], check=False)
pydocstyle_returncode = run(
Expand Down

0 comments on commit 00ec6e0

Please sign in to comment.