From 76e4b8134f45cf706be7d6124dbe5e2d03f71548 Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:48:57 -0700 Subject: [PATCH] skip pylint migrations check if no migrations exist (#51) --- tasks.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tasks.py b/tasks.py index 51128ab..3409626 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") / Path("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)