Skip to content

Commit

Permalink
Ruff, Poetry Lock and change fragment.
Browse files Browse the repository at this point in the history
  • Loading branch information
smk4664 committed Sep 4, 2024
1 parent 374f1da commit bfa55d3
Show file tree
Hide file tree
Showing 12 changed files with 593 additions and 383 deletions.
1 change: 1 addition & 0 deletions changes/266.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rebaked from the cookie `nautobot-app-v2.3.2`.
4 changes: 1 addition & 3 deletions development/app_config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ def _main():
**SchemaBuilder().to_json_schema(app_config), # type: ignore
}
app_config = import_module(package_name).config
_enrich_object_schema(
schema, app_config.default_settings, app_config.required_settings
)
_enrich_object_schema(schema, app_config.default_settings, app_config.required_settings)
schema_path.write_text(json.dumps(schema, indent=4) + "\n")
print(f"\n==================\nGenerated schema:\n\n{schema_path}\n")
print(
Expand Down
12 changes: 3 additions & 9 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@

if "debug_toolbar" not in INSTALLED_APPS: # noqa: F405
INSTALLED_APPS.append("debug_toolbar") # noqa: F405
if (
"debug_toolbar.middleware.DebugToolbarMiddleware" not in MIDDLEWARE
): # noqa: F405
MIDDLEWARE.insert(
0, "debug_toolbar.middleware.DebugToolbarMiddleware"
) # noqa: F405
if "debug_toolbar.middleware.DebugToolbarMiddleware" not in MIDDLEWARE: # noqa: F405
MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa: F405

#
# Misc. settings
Expand Down Expand Up @@ -55,9 +51,7 @@
"NAUTOBOT_DB_PORT",
default_db_settings[nautobot_db_engine]["NAUTOBOT_DB_PORT"],
), # Database port, default to postgres
"CONN_MAX_AGE": int(
os.getenv("NAUTOBOT_DB_TIMEOUT", "300")
), # Database timeout
"CONN_MAX_AGE": int(os.getenv("NAUTOBOT_DB_TIMEOUT", "300")), # Database timeout
"ENGINE": nautobot_db_engine,
}
}
Expand Down
5 changes: 2 additions & 3 deletions nautobot_firewall_models/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ def validate(self, data):
if vrf is not None:
if qs.filter(start_address=start_address, end_address=end_address, vrf=vrf).exists():
raise serializers.ValidationError("The fields start_address, end_address, vrf must make a unique set.")
else:
if qs.filter(start_address=start_address, end_address=end_address, vrf__isnull=True).exists():
raise serializers.ValidationError("The fields start_address, end_address must make a unique set.")
elif qs.filter(start_address=start_address, end_address=end_address, vrf__isnull=True).exists():
raise serializers.ValidationError("The fields start_address, end_address must make a unique set.")

return super().validate(data)

Expand Down
2 changes: 1 addition & 1 deletion nautobot_firewall_models/tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Create basic objects for use in test class setup."""

# noqa: F403, F405
# ruff: noqa: F403, F405
from django.contrib.contenttypes.models import ContentType
from nautobot.dcim.models import Device, DeviceType, Location, LocationType, Manufacturer, Platform
from nautobot.extras.models import DynamicGroup, Job, Role
Expand Down
18 changes: 4 additions & 14 deletions nautobot_firewall_models/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,11 @@ class TestDocsPackaging(unittest.TestCase):

def test_version(self):
"""Verify that pyproject.toml dev dependencies have the same versions as in the docs requirements.txt."""
parent_path = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
)
parent_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
poetry_path = os.path.join(parent_path, "pyproject.toml")
poetry_details = toml.load(poetry_path)["tool"]["poetry"]["group"]["dev"][
"dependencies"
]
with open(
f"{parent_path}/docs/requirements.txt", "r", encoding="utf-8"
) as file:
requirements = [
line
for line in file.read().splitlines()
if (len(line) > 0 and not line.startswith("#"))
]
poetry_details = toml.load(poetry_path)["tool"]["poetry"]["group"]["dev"]["dependencies"]
with open(f"{parent_path}/docs/requirements.txt", "r", encoding="utf-8") as file:
requirements = [line for line in file.read().splitlines() if (len(line) > 0 and not line.startswith("#"))]
for pkg in requirements:
package_name = pkg
if len(pkg.split("==")) == 2: # noqa: PLR2004
Expand Down
2 changes: 1 addition & 1 deletion nautobot_firewall_models/tests/test_capirca.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test Capirca Utils."""

# noqa: F403, F405
# ruff: noqa: F403, F405
# pylint: disable=protected-access
from unittest import skip
from unittest.mock import patch
Expand Down
2 changes: 1 addition & 1 deletion nautobot_firewall_models/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test Firewall models."""

# noqa: F403, F405
# ruff: noqa: F403, F405
# pylint: disable=invalid-name
from django.core.exceptions import ValidationError
from django.test import TestCase
Expand Down
2 changes: 1 addition & 1 deletion nautobot_firewall_models/tests/test_ui_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Unit tests for views."""

# noqa: F403, F405
# ruff: noqa: F403, F405
# pylint: disable=invalid-name
# pylint: disable=duplicate-code
from nautobot.apps.testing import ViewTestCases
Expand Down
Loading

0 comments on commit bfa55d3

Please sign in to comment.