From 9ddd1af98b9518f003e931a1e805d6c0c38bc93e Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:29:09 -0700 Subject: [PATCH 1/2] skip pylint migrations check if no migrations exist --- tasks.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tasks.py b/tasks.py index 51128ab..168210a 100644 --- a/tasks.py +++ b/tasks.py @@ -716,14 +716,18 @@ def pylint(context): 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 + # run the pylint_django migrations checkers on the migrations directory, if one exists + migrations_dir = Path(__file__).absolute().parent / Path("nautobot_dev_example/migrations") + if migrations_dir.is_dir(): + migrations_pylint_command = ( + f"{base_pylint_command} --load-plugins=pylint_django.checkers.migrations" + " --disable=all --enable=fatal,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 + else: + print("No migrations directory found, skipping migrations checks.") raise Exit(code=exit_code) From 55249d0ab90466e999f6a428c308630bc1dccbb7 Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:31:47 -0700 Subject: [PATCH 2/2] path nitpick --- tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index 168210a..3409626 100644 --- a/tasks.py +++ b/tasks.py @@ -717,7 +717,7 @@ def pylint(context): exit_code = 1 # run the pylint_django migrations checkers on the migrations directory, if one exists - migrations_dir = Path(__file__).absolute().parent / Path("nautobot_dev_example/migrations") + migrations_dir = Path(__file__).absolute().parent / Path("nautobot_dev_example") / Path("migrations") if migrations_dir.is_dir(): migrations_pylint_command = ( f"{base_pylint_command} --load-plugins=pylint_django.checkers.migrations"