Skip to content

Commit

Permalink
skip pylint migrations check if no migrations exist
Browse files Browse the repository at this point in the history
  • Loading branch information
gsnider2195 committed Oct 7, 2024
1 parent 1bbccae commit 9ddd1af
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 9ddd1af

Please sign in to comment.