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

Run latest pylint-nautobot #3

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
45 changes: 41 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,48 @@ def hadolint(context):
run_command(context, command)


@task
def pylint(context):
@task(
help={
"latest": "Use the latest version of pylint-nautobot from GitHub.",
"local_pylint_path": "Path to a local pylint-nautobot repository to use for analysis.",
}
)
def pylint(context, latest=False, local_pylint_path=""):
"""Run pylint code analysis."""
command = 'pylint --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml nautobot_dev_example'
run_command(context, command)
command = [
"pylint",
'--init-hook="import nautobot; nautobot.setup()"',
"--rcfile=pyproject.toml",
"nautobot_dev_example",
]

if not latest and not local_pylint_path:
run_command(context, " ".join(command))
return

if local_pylint_path:
local_pylint_path = str(Path(local_pylint_path).resolve().absolute())

command = [
cmsirbu marked this conversation as resolved.
Show resolved Hide resolved
"pip install",
f"-e {local_pylint_path}" if local_pylint_path else "git+https://github.com/nautobot/pylint-nautobot.git",
"&&",
*command,
]

if is_truthy(context.nautobot_dev_example.local):
cmsirbu marked this conversation as resolved.
Show resolved Hide resolved
context.run(" ".join(command))
return

command = [
"run --rm --entrypoint=''",
f"--volume {local_pylint_path}:{local_pylint_path}" if local_pylint_path else "",
"-- nautobot sh -c '",
*command,
"'",
]

docker_compose(context, " ".join(command))


@task(aliases=("a",))
Expand Down
Loading