Skip to content

Commit

Permalink
Merge pull request #202 from nautobot/u/snaselj-ruff
Browse files Browse the repository at this point in the history
Replace pydocstyle with ruff
  • Loading branch information
whitej6 authored Jan 8, 2024
2 parents 2a5d75e + f6cd390 commit 7c1e216
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 239 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: bandit"
run: "poetry run invoke bandit"
pydocstyle:
ruff:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_FIREWALL_MODELS_LOCAL: "True"
Expand All @@ -47,8 +47,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: pydocstyle"
run: "poetry run invoke pydocstyle"
- name: "Linting: ruff"
run: "poetry run invoke ruff"
check-docs-build:
runs-on: "ubuntu-22.04"
env:
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
pylint:
needs:
- "bandit"
- "pydocstyle"
- "ruff"
- "flake8"
- "poetry"
- "yamllint"
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
check-migrations:
needs:
- "bandit"
- "pydocstyle"
- "ruff"
- "flake8"
- "poetry"
- "yamllint"
Expand Down
1 change: 1 addition & 0 deletions changes/202.changed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replaced `pydocstyle` with `ruff`.
2 changes: 1 addition & 1 deletion docs/dev/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The project is packaged with a light [development environment](dev_environment.m

The project is following Network to Code software development guidelines and is leveraging the following:

- Python linting and formatting: `black`, `pylint`, `bandit`, `flake8`, and `pydocstyle`.
- Python linting and formatting: `black`, `pylint`, `bandit`, `flake8`, and `ruff`.
- YAML linting is done with `yamllint`.
- Django unit test to ensure the app is working properly.

Expand Down
4 changes: 2 additions & 2 deletions docs/dev/dev_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Each command can be executed with `invoke <command>`. All commands support the a
bandit Run bandit to validate basic static code security analysis.
black Run black to check that Python files adhere to its style standards.
flake8 Run flake8 to check that Python files adhere to its style standards.
pydocstyle Run pydocstyle to validate docstring formatting adheres to NTC defined standards.
ruff Run ruff to validate docstring formatting adheres to NTC defined standards.
pylint Run pylint code analysis.
tests Run all tests for this app.
unittest Run Django unit tests for the app.
Expand Down Expand Up @@ -467,6 +467,6 @@ To run an individual test, you can run any or all of the following:
➜ invoke bandit
➜ invoke black
➜ invoke flake8
➜ invoke pydocstyle
➜ invoke ruff
➜ invoke pylint
```
1 change: 1 addition & 0 deletions nautobot_firewall_models/management/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Management for Nautobot Firewall Models."""
1 change: 1 addition & 0 deletions nautobot_firewall_models/management/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Management Commands for Nautobot Firewall Models."""
4 changes: 0 additions & 4 deletions nautobot_firewall_models/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class IPRangeAPIViewTest(APIViewTestCases.APIViewTestCase):
@classmethod
def setUpTestData(cls):
"""Create test data for API calls."""

cls.create_data = [
{"start_address": "10.0.0.1", "end_address": "10.0.0.3"},
{"start_address": "10.0.0.4", "end_address": "10.0.0.10"},
Expand All @@ -39,7 +38,6 @@ class FQDNAPIViewTest(APIViewTestCases.APIViewTestCase):
@classmethod
def setUpTestData(cls):
"""Create test data for API calls."""

cls.create_data = [
{"name": "test.local"},
{"name": "sub.test.local"},
Expand Down Expand Up @@ -181,7 +179,6 @@ class UserObjectAPIViewTest(APIViewTestCases.APIViewTestCase):
@classmethod
def setUpTestData(cls):
"""Create test data for API calls."""

cls.create_data = [
{"username": "test1", "name": "Foo"},
{"username": "test2", "name": "Bar"},
Expand Down Expand Up @@ -222,7 +219,6 @@ class ZoneAPIViewTest(APIViewTestCases.APIViewTestCase):
@classmethod
def setUpTestData(cls):
"""Create test data for API calls."""

cls.create_data = [
{"name": "trust"},
{"name": "untrust"},
Expand Down
8 changes: 3 additions & 5 deletions nautobot_firewall_models/tests/test_capirca.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def setUp(self) -> None:
create_capirca_env()

def test_generate_capirca_config(self):
"""Test the implementation of capirca"""
"""Test the implementation of capirca."""
# This partially tests the underlying library, but kept since it helps ensure that overloading
# ParseServiceList and ParseNetworkList continue to work. As well as provides an easy place to test locally.
# Such as running `invoke unittest -l nautobot_firewall_models.tests.test_capirca.TestBasicCapirca` and
Expand Down Expand Up @@ -311,7 +311,6 @@ def setUp(self) -> None:

def test_address_skip(self):
"""Check that address objects are found with status active and not found when other."""

self.pol_rule6.source_addresses.set([self.addr_obj4, self.addr_obj5])
self.pol_rule6.validated_save()
_, networkdata, _ = PolicyToCapirca(self.dev_name, self.pol1).validate_capirca_data()
Expand Down Expand Up @@ -350,7 +349,6 @@ def test_address_empty(self):

def test_address_fqdn(self):
"""Test that validation fails on creating an FQDN when using capirca."""

fqdn1 = FQDN.objects.create(name="test.other", status=self.active)
self.addr_obj5.ip_address = None
self.addr_obj5.fqdn = fqdn1
Expand All @@ -371,7 +369,6 @@ def test_address_ip_range(self):

def test_address_group_skip(self):
"""Check that address group objects are found with status active and not found when other."""

self.pol_rule6.source_address_groups.set([self.addr_grp3, self.addr_grp4])
self.pol_rule6.validated_save()
_, networkdata, _ = PolicyToCapirca(self.dev_name, self.pol1).validate_capirca_data()
Expand Down Expand Up @@ -576,6 +573,7 @@ def test_policy_chd_allow_list(self):
self.assertNotIn("other-value", pol[1]["headers"])

def test_policy_ctd_allow_list(self):
"""Test terms can be allowed and not allowed based on custom field."""
self.pol_rule6._custom_field_data = {"ctd_test-custom": "unique-value", "ctd_test-other": "other-value"}
self.pol_rule6.save()
self.device_obj.platform._custom_field_data = {"capirca_allow": ["ctd_test-custom"]}
Expand Down Expand Up @@ -633,7 +631,7 @@ def setUp(self) -> None:

@skip("Not implemented until policy method provided to merge queries provided")
def test_dynamic_group_and_device(self):
pass
"""Test that dynamic groups are created and device is added to it, disabled."""

def test_multi_policy_capirca_config(self):
"""Verify that generating full config for a device is as expected."""
Expand Down
Loading

0 comments on commit 7c1e216

Please sign in to comment.