Skip to content

Commit 3bd6440

Browse files
authored
Cookie updated targeting ltm-2.4 by NetworkToCode Cookie Drift Manager Tool (#1145)
1 parent 48b7f88 commit 3bd6440

4 files changed

Lines changed: 42 additions & 16 deletions

File tree

.cookiecutter.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
"_drift_manager": {
2020
"template": "https://github.com/nautobot/cookiecutter-nautobot-app.git",
2121
"template_dir": "nautobot-app",
22-
"template_ref": "nautobot-app-v2.7.2",
22+
"template_ref": "nautobot-app-v2.7.3",
2323
"cookie_dir": "",
24-
"pull_request_strategy": "update-or-create",
24+
"pull_request_strategy": "create",
2525
"post_actions": [],
2626
"draft": false,
27-
"baked_commit_ref": "31afaef8ebab6d86732e09e8f6de574d5ec442be",
27+
"baked_commit_ref": "3f39b5c0fb00f90c2bb020ab49e780f317115e68",
2828
"drift_managed_branch": "ltm-2.4"
2929
}
3030
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Apache Software License 2.0
22

3-
Copyright (c) 2025, Network to Code, LLC
3+
Copyright (c) 2026, Network to Code, LLC
44

55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Rebaked from the cookie `nautobot-app-v2.7.3`.

tasks.py

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -751,26 +751,46 @@ def hadolint(context):
751751
run_command(context, command)
752752

753753

754-
@task
755-
def pylint(context):
754+
@task(
755+
help={
756+
"target": "Module or file or directory to inspect, repeatable (default: app package)",
757+
"recursive": "Must be set if target is a directory rather than a module or file name",
758+
},
759+
iterable=["target"],
760+
)
761+
def pylint(context, target=None, recursive=False):
756762
"""Run pylint code analysis."""
757763
exit_code = 0
758764

759765
base_pylint_command = 'pylint --verbose --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml'
760-
command = f"{base_pylint_command} nautobot_golden_config"
766+
command = base_pylint_command
767+
if recursive:
768+
command += " --recursive=y"
769+
command += f" {' '.join(target) if target else 'nautobot_golden_config'}"
761770
if not run_command(context, command, warn=True):
762771
exit_code = 1
763772

764773
# run the pylint_django migrations checkers on the migrations directory, if one exists
765-
migrations_dir = Path(__file__).absolute().parent / Path("nautobot_golden_config") / Path("migrations")
774+
app_dir = Path(__file__).absolute().parent / Path("nautobot_golden_config")
775+
migrations_dir = app_dir / Path("migrations")
776+
migrations_target_module = "nautobot_golden_config.migrations"
777+
run_migrations_check = target is None
778+
if target is not None:
779+
for target_item in target:
780+
target_item_normalized = Path(target_item).resolve()
781+
if target_item_normalized in (app_dir, migrations_dir) or target_item == migrations_target_module:
782+
run_migrations_check = True
783+
break
784+
766785
if migrations_dir.is_dir():
767-
migrations_pylint_command = (
768-
f"{base_pylint_command} --load-plugins=pylint_django.checkers.migrations"
769-
" --disable=all --enable=fatal,new-db-field-with-default,missing-backwards-migration-callable"
770-
" nautobot_golden_config.migrations"
771-
)
772-
if not run_command(context, migrations_pylint_command, warn=True):
773-
exit_code = 1
786+
if run_migrations_check:
787+
migrations_pylint_command = (
788+
f"{base_pylint_command} --load-plugins=pylint_django.checkers.migrations"
789+
" --disable=all --enable=fatal,new-db-field-with-default,missing-backwards-migration-callable"
790+
" nautobot_golden_config.migrations"
791+
)
792+
if not run_command(context, migrations_pylint_command, warn=True):
793+
exit_code = 1
774794
else:
775795
print("No migrations directory found, skipping migrations checks.")
776796

@@ -790,11 +810,12 @@ def autoformat(context):
790810
"action": "Available values are `['lint', 'format']`. Can be used multiple times. (default: `--action lint --action format`)",
791811
"target": "File or directory to inspect, repeatable (default: all files in the project will be inspected)",
792812
"fix": "Automatically fix selected actions. May not be able to fix all issues found. (default: False)",
813+
"diff": "Show diffs of changes. (default: False)",
793814
"output_format": "See https://docs.astral.sh/ruff/settings/#output-format for details. (default: `concise`)",
794815
},
795816
iterable=["action", "target"],
796817
)
797-
def ruff(context, action=None, target=None, fix=False, output_format="concise"):
818+
def ruff(context, action=None, target=None, fix=False, diff=False, output_format="concise"): # noqa: PLR0913
798819
"""Run ruff to perform code formatting and/or linting."""
799820
if not action:
800821
action = ["lint", "format"]
@@ -807,6 +828,8 @@ def ruff(context, action=None, target=None, fix=False, output_format="concise"):
807828
command = "ruff format "
808829
if not fix:
809830
command += "--check "
831+
if diff:
832+
command += "--diff "
810833
command += " ".join(target)
811834
if not run_command(context, command, warn=True):
812835
exit_code = 1
@@ -815,6 +838,8 @@ def ruff(context, action=None, target=None, fix=False, output_format="concise"):
815838
command = "ruff check "
816839
if fix:
817840
command += "--fix "
841+
elif diff:
842+
command += "--diff "
818843
command += f"--output-format {output_format} "
819844
command += " ".join(target)
820845
if not run_command(context, command, warn=True):

0 commit comments

Comments
 (0)