From 3963dd5e2b37572019554e02f58e2bab9951d920 Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Wed, 2 Oct 2024 11:09:46 -0700 Subject: [PATCH 1/3] add pylint_django migrations check --- tasks.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index d564ba4..709d34f 100644 --- a/tasks.py +++ b/tasks.py @@ -709,8 +709,21 @@ def hadolint(context): @task def pylint(context): """Run pylint code analysis.""" + exit_code = 0 + command = 'pylint --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml nautobot_dev_example' - run_command(context, command) + if not run_command(context, command, warn=True): + exit_code = 1 + + # run the pylint_django migrations checkers on the migrations directory + migrations_pylint = ( + 'pylint --verbose --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml ' + "--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, warn=True): + exit_code = 1 + + raise Exit(code=exit_code) @task(aliases=("a",)) From 2d271a64633243df3e0c2705d799b2f73198b774 Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Wed, 2 Oct 2024 11:39:17 -0700 Subject: [PATCH 2/3] changelog --- changes/50.added | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/50.added 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. From b6f701a47f3b2e3cbe1fc32cad2aa277662c1108 Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:02:25 -0700 Subject: [PATCH 3/3] update pylint task --- tasks.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tasks.py b/tasks.py index 709d34f..51128ab 100644 --- a/tasks.py +++ b/tasks.py @@ -711,16 +711,18 @@ def pylint(context): """Run pylint code analysis.""" exit_code = 0 - command = 'pylint --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml nautobot_dev_example' + 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 = ( - 'pylint --verbose --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml ' - "--load-plugins=pylint_django.checkers.migrations --disable=all --enable=new-db-field-with-default,missing-backwards-migration-callable nautobot_dev_example.migrations" + 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, warn=True): + if not run_command(context, migrations_pylint_command, warn=True): exit_code = 1 raise Exit(code=exit_code)