diff --git a/changes/50.added b/changes/50.added new file mode 100644 index 0000000..c411d61 --- /dev/null +++ b/changes/50.added @@ -0,0 +1 @@ +Added pylint django migrations checker to the `invoke pylint` command. diff --git a/tasks.py b/tasks.py index d564ba4..51128ab 100644 --- a/tasks.py +++ b/tasks.py @@ -709,8 +709,23 @@ def hadolint(context): @task def pylint(context): """Run pylint code analysis.""" - command = 'pylint --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml nautobot_dev_example' - run_command(context, command) + exit_code = 0 + + base_pylint_command = 'pylint --verbose --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml' + command = f"{base_pylint_command} nautobot_dev_example" + if not run_command(context, command, warn=True): + exit_code = 1 + + # run the pylint_django migrations checkers on the migrations directory + migrations_pylint_command = ( + f"{base_pylint_command} --load-plugins=pylint_django.checkers.migrations" + " --disable=all --enable=new-db-field-with-default,missing-backwards-migration-callable" + " nautobot_dev_example.migrations" + ) + if not run_command(context, migrations_pylint_command, warn=True): + exit_code = 1 + + raise Exit(code=exit_code) @task(aliases=("a",))