Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added list of paths to visiumlint argument #15

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/visiumlint/main.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
"""visiumlint main module."""
# pylint: disable=duplicate-code
import sys
from pathlib import Path
from subprocess import run
from typing import List

import typer


def lint(
paths: List[Path] = typer.Argument(default=None, help="Paths of files and directories to visiumlint."),
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 not paths:
paths = [Path(".")]
Gramet marked this conversation as resolved.
Show resolved Hide resolved
if check_lint:
check_lint = "--check"
else:
check_lint = ""

paths = " ".join([str(path) for path in paths if path.is_file() or path.is_dir()])

run(["sh", "-c", "echo 'Running black'"], check=False)
black_returncode = run(["sh", "-c", f"black {check_lint} . --line-length 120"], check=False).returncode
black_returncode = run(["sh", "-c", f"black {paths} {check_lint} --line-length 120"], check=False).returncode

run(["sh", "-c", "echo Running isort"], check=False)
isort_returncode = run(
["sh", "-c", f"isort {check_lint} --gitignore . --line-length 120 --profile black"], check=False
["sh", "-c", f"isort {check_lint} --gitignore {paths} --line-length 120 --profile black"], check=False
).returncode

if not hook:
Expand All @@ -30,7 +37,7 @@ def lint(
[
"sh",
"-c",
"pylint . --recursive=y --load-plugins=pylint.extensions.docstyle,pylint.extensions.docparams --disable=fixme,too-few-public-methods",
f"pylint {paths} --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",
Expand All @@ -45,15 +52,16 @@ def lint(

run(["sh", "-c", "echo Running pydocstyle"], check=False)
pydocstyle_returncode = run(
["sh", "-c", "pydocstyle .", "--add-ignore", "D107, D104, D103", "--convention", "google"], check=False
["sh", "-c", f"pydocstyle {paths}", "--add-ignore", "D107, D104, D103", "--convention", "google"],
check=False,
).returncode

run(["sh", "-c", "echo Running mypy"], check=False)
mypy_returncode = run(
[
"sh",
"-c",
'! mypy . --disallow-untyped-defs --disallow-incomplete-defs | grep "Function is missing" || false',
f'! mypy {paths} --disallow-untyped-defs --disallow-incomplete-defs | grep "Function is missing" || false',
],
check=False,
).returncode
Expand Down
Loading