From 5eb213feb32d6413655eb5e9f73cebf5f4b95b2c Mon Sep 17 00:00:00 2001 From: Kevin Petremann Date: Thu, 8 Aug 2024 18:01:06 +0200 Subject: [PATCH 1/2] ci: add ruff + fix issues --- netbox_cmdb/netbox_cmdb/api/cmdb/views.py | 2 - netbox_cmdb/netbox_cmdb/api/snmp/views.py | 2 - netbox_cmdb/netbox_cmdb/forms.py | 2 - netbox_cmdb/netbox_cmdb/models/bgp.py | 2 +- netbox_cmdb/netbox_cmdb/models/prefix_list.py | 1 - netbox_cmdb/netbox_cmdb/models/snmp.py | 2 - .../tests/bgp/test_bgp_serializer.py | 30 +++++++------- .../test_bgp_community_list_serializer.py | 16 ++++---- .../test_prefix_list_serializer.py | 16 ++++---- .../test_route_policy_serializer.py | 18 ++++----- .../tests/snmp/test_snmp_serializer.py | 8 ++-- netbox_cmdb/netbox_cmdb/urls.py | 2 +- netbox_cmdb/netbox_cmdb/views.py | 9 +---- netbox_cmdb/setup.py | 5 +-- pyproject.toml | 39 ++++++++++++++++++- 15 files changed, 87 insertions(+), 67 deletions(-) diff --git a/netbox_cmdb/netbox_cmdb/api/cmdb/views.py b/netbox_cmdb/netbox_cmdb/api/cmdb/views.py index 98feb60..3d2ea01 100644 --- a/netbox_cmdb/netbox_cmdb/api/cmdb/views.py +++ b/netbox_cmdb/netbox_cmdb/api/cmdb/views.py @@ -1,7 +1,5 @@ from django.db import transaction from django.db.models import Q -from drf_yasg import openapi -from drf_yasg.openapi import Parameter from drf_yasg.utils import swagger_auto_schema from netbox.api.authentication import IsAuthenticatedOrLoginNotRequired from rest_framework import serializers, status diff --git a/netbox_cmdb/netbox_cmdb/api/snmp/views.py b/netbox_cmdb/netbox_cmdb/api/snmp/views.py index 7c95e45..8bb8ab5 100644 --- a/netbox_cmdb/netbox_cmdb/api/snmp/views.py +++ b/netbox_cmdb/netbox_cmdb/api/snmp/views.py @@ -1,7 +1,5 @@ """Route Policy views.""" -from rest_framework.response import Response - from netbox_cmdb import filtersets from netbox_cmdb.api.snmp.serializers import ( SNMPCommunitySerializer, diff --git a/netbox_cmdb/netbox_cmdb/forms.py b/netbox_cmdb/netbox_cmdb/forms.py index cb9bbf9..6ecf4e7 100644 --- a/netbox_cmdb/netbox_cmdb/forms.py +++ b/netbox_cmdb/netbox_cmdb/forms.py @@ -1,7 +1,5 @@ """Forms.""" -from typing import Any, Sequence - from dcim.models import Device from dcim.models.devices import DeviceType from dcim.models.sites import SiteGroup diff --git a/netbox_cmdb/netbox_cmdb/models/bgp.py b/netbox_cmdb/netbox_cmdb/models/bgp.py index bd0f4a6..4aa5799 100644 --- a/netbox_cmdb/netbox_cmdb/models/bgp.py +++ b/netbox_cmdb/netbox_cmdb/models/bgp.py @@ -159,7 +159,7 @@ def get_available_asns(self, min_asn, max_asn): """ Return all available ASNs in a given range. """ - available_asns = {asn for asn in range(min_asn, max_asn + 1)} + available_asns = set(range(min_asn, max_asn + 1)) available_asns -= set(self.__class__.objects.all().values_list("number", flat=True)) return sorted(available_asns) diff --git a/netbox_cmdb/netbox_cmdb/models/prefix_list.py b/netbox_cmdb/netbox_cmdb/models/prefix_list.py index 6567f5e..764ead2 100644 --- a/netbox_cmdb/netbox_cmdb/models/prefix_list.py +++ b/netbox_cmdb/netbox_cmdb/models/prefix_list.py @@ -2,7 +2,6 @@ from django.core.exceptions import ValidationError from django.db import models -from django.urls import reverse from ipam.fields import IPNetworkField from netbox.models import ChangeLoggedModel from utilities.choices import ChoiceSet diff --git a/netbox_cmdb/netbox_cmdb/models/snmp.py b/netbox_cmdb/netbox_cmdb/models/snmp.py index 8099117..327bdab 100644 --- a/netbox_cmdb/netbox_cmdb/models/snmp.py +++ b/netbox_cmdb/netbox_cmdb/models/snmp.py @@ -1,5 +1,3 @@ -from django.contrib.postgres.fields import ArrayField -from django.core.exceptions import ValidationError from django.db import models from netbox.models import ChangeLoggedModel diff --git a/netbox_cmdb/netbox_cmdb/tests/bgp/test_bgp_serializer.py b/netbox_cmdb/netbox_cmdb/tests/bgp/test_bgp_serializer.py index b997c52..0d34f4d 100644 --- a/netbox_cmdb/netbox_cmdb/tests/bgp/test_bgp_serializer.py +++ b/netbox_cmdb/netbox_cmdb/tests/bgp/test_bgp_serializer.py @@ -55,7 +55,7 @@ def test_create(self): "ecmp_maximum_paths": 128, } bgp_global_serializer = BGPGlobalSerializer(data=data) - assert bgp_global_serializer.is_valid() == True + assert bgp_global_serializer.is_valid() is True bgp_global_serializer.save() global_conf = BGPGlobal.objects.get(device__name="router-test1") @@ -64,9 +64,9 @@ def test_create(self): assert global_conf.local_asn_id == 5 assert global_conf.ebgp_administrative_distance == 20 assert global_conf.ibgp_administrative_distance == 170 - assert global_conf.graceful_restart == True + assert global_conf.graceful_restart is True assert global_conf.graceful_restart_time == 240 - assert global_conf.ecmp == True + assert global_conf.ecmp is True assert global_conf.ecmp_maximum_paths == 128 @@ -98,7 +98,7 @@ def test_already_existing(self): "ecmp_maximum_paths": 128, } bgp_global_serializer = BGPGlobalSerializer(data=data) - assert bgp_global_serializer.is_valid() == True + assert bgp_global_serializer.is_valid() is True self.assertRaises(IntegrityError, bgp_global_serializer.save) def test_update(self): @@ -114,7 +114,7 @@ def test_update(self): "ecmp_maximum_paths": 128, } bgp_global_serializer = BGPGlobalSerializer(instance=self.global_conf1, data=data) - assert bgp_global_serializer.is_valid() == True + assert bgp_global_serializer.is_valid() is True bgp_global_serializer.save() global_conf = BGPGlobal.objects.get(device__name="router-test1") @@ -148,7 +148,7 @@ def test_bgp_session_creation(self): } bgp_session_serializer = BGPSessionSerializer(data=data) - assert bgp_session_serializer.is_valid() == True + assert bgp_session_serializer.is_valid() is True bgp_session_serializer.save() bgp_session_got = BGPSession.objects.get( @@ -280,7 +280,7 @@ def test_bgp_session_add__existing_session(self): "password": "1234", } bgp_session_serializer = BGPSessionSerializer(data=data) - assert bgp_session_serializer.is_valid() == False + assert bgp_session_serializer.is_valid() is False assert bgp_session_serializer.errors["errors"][0] == ErrorDetail( string="[ErrorDetail(string='A BGP session already exists between these 2 devices and IP addresses.', code='invalid')]", code="invalid", @@ -311,7 +311,7 @@ def test_bgp_session_update__state_and_password(self): } bgp_session_serializer = BGPSessionSerializer(instance=self.bgp_session, data=data) - assert bgp_session_serializer.is_valid() == True + assert bgp_session_serializer.is_valid() is True bgp_session_serializer.save() bgp_session_got = BGPSession.objects.get(id=self.bgp_session.pk) @@ -345,14 +345,14 @@ def test_bgp_session_update__modify_peer(self): "password": "1234", } bgp_session_serializer = BGPSessionSerializer(instance=self.bgp_session, data=data) - assert bgp_session_serializer.is_valid() == True + assert bgp_session_serializer.is_valid() is True bgp_session_serializer.save() bgp_session_got = BGPSession.objects.get(id=self.bgp_session.pk) assert bgp_session_got.peer_a.description == "peer_a" assert bgp_session_got.peer_a.maximum_prefixes == 50000 assert bgp_session_got.peer_a.enabled is False - assert bgp_session_got.peer_a.enforce_first_as == False + assert bgp_session_got.peer_a.enforce_first_as is False assert bgp_session_got.peer_b.description == "peer_b" assert bgp_session_got.peer_b.enabled is True @@ -373,7 +373,7 @@ def test_bgp_session_update__patch_peer_a_route_policy(self): }, } bgp_session_serializer = BGPSessionSerializer(instance=self.bgp_session, data=data) - assert bgp_session_serializer.is_valid() == True + assert bgp_session_serializer.is_valid() is True bgp_session_serializer.save() bgp_session_got = BGPSession.objects.get(id=self.bgp_session.pk) @@ -383,11 +383,11 @@ def test_bgp_session_update__patch_peer_a_route_policy(self): data["peer_a"]["route_policy_out"] = None bgp_session_serializer = BGPSessionSerializer(instance=self.bgp_session, data=data) - assert bgp_session_serializer.is_valid() == True + assert bgp_session_serializer.is_valid() is True bgp_session_serializer.save() bgp_session_got = BGPSession.objects.get(id=self.bgp_session.pk) - assert bgp_session_got.peer_a.route_policy_out == None + assert bgp_session_got.peer_a.route_policy_out is None def test_bgp_session_update__add_afisafi(self): """Adding ipv4-unicast afisafi to an existing session""" @@ -415,7 +415,7 @@ def test_bgp_session_update__add_afisafi(self): } bgp_session_serializer = BGPSessionSerializer(instance=self.bgp_session, data=data) - assert bgp_session_serializer.is_valid() == True + assert bgp_session_serializer.is_valid() is True bgp_session_serializer.save() def test_bgp_session_update__replace_afisafi(self): @@ -451,7 +451,7 @@ def test_bgp_session_update__replace_afisafi(self): } bgp_session_serializer = BGPSessionSerializer(instance=self.bgp_session, data=data) - assert bgp_session_serializer.is_valid() == True + assert bgp_session_serializer.is_valid() is True bgp_session_serializer.save() # check in database that the object has been modified diff --git a/netbox_cmdb/netbox_cmdb/tests/bgp_community_list/test_bgp_community_list_serializer.py b/netbox_cmdb/netbox_cmdb/tests/bgp_community_list/test_bgp_community_list_serializer.py index d2a7eca..cf819a9 100644 --- a/netbox_cmdb/netbox_cmdb/tests/bgp_community_list/test_bgp_community_list_serializer.py +++ b/netbox_cmdb/netbox_cmdb/tests/bgp_community_list/test_bgp_community_list_serializer.py @@ -66,7 +66,7 @@ def test_bgp_community_list_creation(self): } bgp_com_list_serializer = BGPCommunityListSerializer(data=data) - assert bgp_com_list_serializer.is_valid() == True + assert bgp_com_list_serializer.is_valid() is True def test_bgp_community_list_creation_with_empty_terms(self): data = { @@ -76,7 +76,7 @@ def test_bgp_community_list_creation_with_empty_terms(self): } bgp_com_list_serializer = BGPCommunityListSerializer(data=data) - assert bgp_com_list_serializer.is_valid() == True + assert bgp_com_list_serializer.is_valid() is True with self.assertRaisesRegex( ValidationError, @@ -91,7 +91,7 @@ def test_bgp_community_list_creation_without_terms(self): } bgp_com_list_serializer = BGPCommunityListSerializer(data=data) - assert bgp_com_list_serializer.is_valid() == False + assert bgp_com_list_serializer.is_valid() is False class BGPCommunityListSerializerUpdate(BaseTestCase): @@ -136,7 +136,7 @@ def test_bgp_community_list_update_add_term(self): ], } bgp_com_list_serializer = BGPCommunityListSerializer(instance=self.prefix_list, data=data) - assert bgp_com_list_serializer.is_valid() == True + assert bgp_com_list_serializer.is_valid() is True bgp_com_list_serializer.save() validate(self.device, data) @@ -152,7 +152,7 @@ def test_bgp_community_list_update_remove_term(self): ], } bgp_com_list_serializer = BGPCommunityListSerializer(instance=self.prefix_list, data=data) - assert bgp_com_list_serializer.is_valid() == True + assert bgp_com_list_serializer.is_valid() is True bgp_com_list_serializer.save() validate(self.device, data) @@ -172,7 +172,7 @@ def test_bgp_community_list_update_replace_terms(self): ], } bgp_com_list_serializer = BGPCommunityListSerializer(instance=self.prefix_list, data=data) - assert bgp_com_list_serializer.is_valid() == True + assert bgp_com_list_serializer.is_valid() is True bgp_com_list_serializer.save() validate(self.device, data) @@ -193,7 +193,7 @@ def test_bgp_community_list_update_attr_term(self): ], } bgp_com_list_serializer = BGPCommunityListSerializer(instance=self.prefix_list, data=data) - assert bgp_com_list_serializer.is_valid() == True + assert bgp_com_list_serializer.is_valid() is True bgp_com_list_serializer.save() validate(self.device, data) @@ -204,7 +204,7 @@ def test_bgp_community_list_update_no_terms(self): "terms": [], } bgp_com_list_serializer = BGPCommunityListSerializer(instance=self.prefix_list, data=data) - assert bgp_com_list_serializer.is_valid() == True + assert bgp_com_list_serializer.is_valid() is True with self.assertRaisesRegex( ValidationError, diff --git a/netbox_cmdb/netbox_cmdb/tests/prefix_list/test_prefix_list_serializer.py b/netbox_cmdb/netbox_cmdb/tests/prefix_list/test_prefix_list_serializer.py index ca2b076..332a94d 100644 --- a/netbox_cmdb/netbox_cmdb/tests/prefix_list/test_prefix_list_serializer.py +++ b/netbox_cmdb/netbox_cmdb/tests/prefix_list/test_prefix_list_serializer.py @@ -69,7 +69,7 @@ def test_prefix_list_creation(self): } pf_serializer = PrefixListSerializer(data=data) - assert pf_serializer.is_valid() == True + assert pf_serializer.is_valid() is True def test_prefix_list_creation_with_empty_terms(self): data = { @@ -80,7 +80,7 @@ def test_prefix_list_creation_with_empty_terms(self): } pf_serializer = PrefixListSerializer(data=data) - assert pf_serializer.is_valid() == True + assert pf_serializer.is_valid() is True with self.assertRaisesRegex( ValidationError, @@ -96,7 +96,7 @@ def test_prefix_list_creation_without_terms(self): } pf_serializer = PrefixListSerializer(data=data) - assert pf_serializer.is_valid() == False + assert pf_serializer.is_valid() is False class PrefixListSerializerUpdate(BaseTestCase): @@ -143,7 +143,7 @@ def test_prefix_list_update_add_term(self): ], } pf_serializer = PrefixListSerializer(instance=self.prefix_list, data=data) - assert pf_serializer.is_valid() == True + assert pf_serializer.is_valid() is True pf_serializer.save() validate(self.device, data) @@ -161,7 +161,7 @@ def test_prefix_list_update_remove_term(self): ], } pf_serializer = PrefixListSerializer(instance=self.prefix_list, data=data) - assert pf_serializer.is_valid() == True + assert pf_serializer.is_valid() is True pf_serializer.save() validate(self.device, data) @@ -184,7 +184,7 @@ def test_prefix_list_update_replace_terms(self): ], } pf_serializer = PrefixListSerializer(instance=self.prefix_list, data=data) - assert pf_serializer.is_valid() == True + assert pf_serializer.is_valid() is True pf_serializer.save() validate(self.device, data) @@ -206,7 +206,7 @@ def test_prefix_list_update_attr_term(self): ], } pf_serializer = PrefixListSerializer(instance=self.prefix_list, data=data) - assert pf_serializer.is_valid() == True + assert pf_serializer.is_valid() is True pf_serializer.save() validate(self.device, data) @@ -218,7 +218,7 @@ def test_prefix_list_update_no_terms(self): "terms": [], } pf_serializer = PrefixListSerializer(instance=self.prefix_list, data=data) - assert pf_serializer.is_valid() == True + assert pf_serializer.is_valid() is True with self.assertRaisesRegex( ValidationError, diff --git a/netbox_cmdb/netbox_cmdb/tests/route_policy/test_route_policy_serializer.py b/netbox_cmdb/netbox_cmdb/tests/route_policy/test_route_policy_serializer.py index 730822f..1c0b7fa 100644 --- a/netbox_cmdb/netbox_cmdb/tests/route_policy/test_route_policy_serializer.py +++ b/netbox_cmdb/netbox_cmdb/tests/route_policy/test_route_policy_serializer.py @@ -128,7 +128,7 @@ def test_route_policy_creation(self): } route_policy_serializer = WritableRoutePolicySerializer(data=data) - assert route_policy_serializer.is_valid() == True + assert route_policy_serializer.is_valid() is True def test_route_policy_creation_with_empty_terms(self): data = { @@ -138,7 +138,7 @@ def test_route_policy_creation_with_empty_terms(self): } route_policy_serializer = WritableRoutePolicySerializer(data=data) - assert route_policy_serializer.is_valid() == True + assert route_policy_serializer.is_valid() is True with self.assertRaisesRegex( ValidationError, @@ -153,7 +153,7 @@ def test_route_policycreation_without_terms(self): } route_policy_serializer = WritableRoutePolicySerializer(data=data) - assert route_policy_serializer.is_valid() == False + assert route_policy_serializer.is_valid() is False class WritableRoutePolicySerializerUpdate(BaseTestCase): @@ -209,7 +209,7 @@ def test_route_policy_update_add_term(self): route_policy_serializer = WritableRoutePolicySerializer( instance=self.route_policy, data=data ) - assert route_policy_serializer.is_valid() == True + assert route_policy_serializer.is_valid() is True route_policy_serializer.save() validate(self.device, data) @@ -240,7 +240,7 @@ def test_route_policy_update_add_invalid_term(self): route_policy_serializer = WritableRoutePolicySerializer( instance=self.route_policy, data=data ) - assert route_policy_serializer.is_valid() == False + assert route_policy_serializer.is_valid() is False def test_route_policy_update_remove_term(self): data = { @@ -258,7 +258,7 @@ def test_route_policy_update_remove_term(self): route_policy_serializer = WritableRoutePolicySerializer( instance=self.route_policy, data=data ) - assert route_policy_serializer.is_valid() == True + assert route_policy_serializer.is_valid() is True route_policy_serializer.save() validate(self.device, data) @@ -284,7 +284,7 @@ def test_route_policy_update_replace_terms(self): route_policy_serializer = WritableRoutePolicySerializer( instance=self.route_policy, data=data ) - assert route_policy_serializer.is_valid() == True + assert route_policy_serializer.is_valid() is True route_policy_serializer.save() validate(self.device, data) @@ -311,7 +311,7 @@ def test_route_policy_update_attr_term(self): route_policy_serializer = WritableRoutePolicySerializer( instance=self.route_policy, data=data ) - assert route_policy_serializer.is_valid() == True + assert route_policy_serializer.is_valid() is True route_policy_serializer.save() validate(self.device, data) @@ -356,7 +356,7 @@ def test_route_policy_update_no_terms(self): route_policy_serializer = WritableRoutePolicySerializer( instance=self.route_policy, data=data ) - assert route_policy_serializer.is_valid() == True + assert route_policy_serializer.is_valid() is True with self.assertRaisesRegex( ValidationError, diff --git a/netbox_cmdb/netbox_cmdb/tests/snmp/test_snmp_serializer.py b/netbox_cmdb/netbox_cmdb/tests/snmp/test_snmp_serializer.py index ed99709..192f0ba 100644 --- a/netbox_cmdb/netbox_cmdb/tests/snmp/test_snmp_serializer.py +++ b/netbox_cmdb/netbox_cmdb/tests/snmp/test_snmp_serializer.py @@ -8,7 +8,7 @@ class SNMPCommunitySerializerCreate(BaseTestCase): def test_create(self): data = {"name": "my_comm1", "community": "my_community", "type": "readonly"} snmpcommunity_serializer = SNMPCommunitySerializer(data=data) - assert snmpcommunity_serializer.is_valid() == True + assert snmpcommunity_serializer.is_valid() is True snmpcommunity_serializer.save() community1 = SNMPCommunity.objects.get(name="my_comm1") @@ -25,7 +25,7 @@ def test_create(self): } snmp_serializer = SNMPSerializer(data=data) - assert snmp_serializer.is_valid() == True + assert snmp_serializer.is_valid() is True snmp_serializer.save() conf = SNMP.objects.get(device__name=self.device1.name) @@ -37,7 +37,7 @@ def test_create(self): data = {"name": "my_comm2", "community": "my_community2", "type": "readonly"} snmpcommunity_serializer = SNMPCommunitySerializer(data=data) - assert snmpcommunity_serializer.is_valid() == True + assert snmpcommunity_serializer.is_valid() is True snmpcommunity_serializer.save() community2 = SNMPCommunity.objects.get(name="my_comm2") @@ -50,4 +50,4 @@ def test_create(self): snmp_serializer = SNMPSerializer(data=data) # We are trying to add more than 1 community to the device - assert snmp_serializer.is_valid() == False + assert snmp_serializer.is_valid() is False diff --git a/netbox_cmdb/netbox_cmdb/urls.py b/netbox_cmdb/netbox_cmdb/urls.py index 72ae4c8..5324fcb 100644 --- a/netbox_cmdb/netbox_cmdb/urls.py +++ b/netbox_cmdb/netbox_cmdb/urls.py @@ -3,7 +3,7 @@ from django.urls import path from netbox.views.generic import ObjectChangeLogView, ObjectJournalView -from netbox_cmdb.models.bgp import * +from netbox_cmdb.models.bgp import ASN, BGPSession, DeviceBGPSession, BGPPeerGroup from netbox_cmdb.models.route_policy import RoutePolicy from netbox_cmdb.models.snmp import SNMP, SNMPCommunity from netbox_cmdb.views import ( diff --git a/netbox_cmdb/netbox_cmdb/views.py b/netbox_cmdb/netbox_cmdb/views.py index 1dc7fec..a14ce5f 100644 --- a/netbox_cmdb/netbox_cmdb/views.py +++ b/netbox_cmdb/netbox_cmdb/views.py @@ -1,14 +1,9 @@ """Views.""" -import logging -import time - from dcim.models import Device from django.db import transaction from django.db.models import Q from django.shortcuts import render -from django.urls import reverse -from django.views.generic import View from netbox.views.generic import ( ObjectDeleteView, ObjectEditView, @@ -16,11 +11,9 @@ ObjectView, ) from netbox.views.generic.bulk_views import BulkDeleteView -from rest_framework import status -from rest_framework.response import Response from utilities.forms import ConfirmationForm from utilities.htmx import is_htmx -from utilities.utils import count_related, get_viewname +from utilities.utils import count_related from netbox_cmdb.filtersets import ( ASNFilterSet, diff --git a/netbox_cmdb/setup.py b/netbox_cmdb/setup.py index a30409e..70a8150 100644 --- a/netbox_cmdb/setup.py +++ b/netbox_cmdb/setup.py @@ -1,7 +1,7 @@ import codecs import os.path -from setuptools import find_namespace_packages, find_packages, setup +from setuptools import find_namespace_packages, setup def read(rel_path): @@ -15,8 +15,7 @@ def get_version(rel_path): if line.startswith("__version__"): delim = '"' if '"' in line else "'" return line.split(delim)[1] - else: - raise RuntimeError("Unable to find version string.") + raise RuntimeError("Unable to find version string.") setup( diff --git a/pyproject.toml b/pyproject.toml index 60999ab..ab15544 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,40 @@ +[tool.ruff] +line-length = 100 + +[tool.ruff.lint] +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "C", # flake8-comprehensions + "B", # flake8-bugbear + "ASYNC", # flake8-async + "C4", # flake8-comprehensions + "G", # flake8-logging-format + "S", # bandit + "PL" # pylint +] +ignore = [ + "E501", # line too long, handled by black + "C901", # function is too complex + "PLR2004", # magic value used in comparison + "PLR1711", # useless `return` statement at end of function + "PLC1901", # compare-to-empty-string + "PLR0911", # too many return statements + "PLR0912", # too many branches + "PLR0915", # too many statements + "B009", # do not call getattr with a constant attribute value + "B904", # raise without from inside except + "S311", # standard pseudo-random generators are not suitable for cryptographic purposes +] + +[tool.ruff.lint.pylint] +max-args = 10 + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401", "F403"] +"netbox_cmdb/netbox_cmdb/tests/**.py" = ["E402", "S", "PL"] + [tool.black] line-length = 100 exclude = ''' @@ -20,4 +57,4 @@ exclude = ''' profile = "black" multi_line_output = 3 skip_gitignore = true -skip = ".bzr,.direnv,.eggs,.git,.hg,.mypy_cache,.nox,.pants.d,.svn,.tox,.venv,_build,buck-out,build,dist,node_modules,venv,migrations,urls.py" \ No newline at end of file +skip = ".bzr,.direnv,.eggs,.git,.hg,.mypy_cache,.nox,.pants.d,.svn,.tox,.venv,_build,buck-out,build,dist,node_modules,venv,migrations,urls.py" From 54934a44b3640541f465ab31e0f3029bf5dced1b Mon Sep 17 00:00:00 2001 From: Kevin Petremann Date: Thu, 8 Aug 2024 18:23:45 +0200 Subject: [PATCH 2/2] ci: ruff and isort in github action --- .github/workflows/ci.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 255b0cb..06f490c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,11 +17,16 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install black + pip install black isort ruff - - name: Check black formatting - run: | - black . --check + - name: Lint with Ruff + run: ruff check . + + - name: Lint with Black + run: black . --check --diff + + - name: Lint with isort + run: isort . --check --diff - name: Run tests in containers run: |