Skip to content

Commit

Permalink
Pylint improvements applied
Browse files Browse the repository at this point in the history
  • Loading branch information
peteeckel committed Oct 19, 2023
1 parent fdb2e5e commit 16eda64
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 40 deletions.
3 changes: 2 additions & 1 deletion netbox_dns/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from extras.plugins import PluginConfig
import logging

from extras.plugins import PluginConfig

logger = logging.getLogger("netbox.config")

__version__ = "0.20.1"
Expand Down
1 change: 0 additions & 1 deletion netbox_dns/fields/address.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django import forms
from django.db import models
from django.db.models import Lookup
from django.core.exceptions import ValidationError

from netaddr import AddrFormatError, IPAddress
Expand Down
1 change: 0 additions & 1 deletion netbox_dns/filters/nameserver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import django_filters
from django.db.models import Q

from netbox.filtersets import NetBoxModelFilterSet
Expand Down
1 change: 0 additions & 1 deletion netbox_dns/filters/view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import django_filters
from django.db.models import Q

from netbox.filtersets import NetBoxModelFilterSet
Expand Down
2 changes: 1 addition & 1 deletion netbox_dns/forms/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def clean_soa_ttl(self):

def clean_soa_mname(self):
soa_mname = self._clean_field_with_defaults("soa_mname")
if type(soa_mname) == str:
if isinstance(soa_mname, str):
try:
soa_mname = NameServer.objects.get(name=soa_mname)
except NameServer.DoesNotExist:
Expand Down
6 changes: 3 additions & 3 deletions netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Generated by Django 4.1.2 on 2022-11-30 15:35
import taggit.managers

import django.core.serializers.json
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models

import netbox_dns.fields.network
import taggit.managers


class Migration(migrations.Migration):
Expand Down
11 changes: 5 additions & 6 deletions netbox_dns/migrations/0021_record_ip_address.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Generated by Django 4.1.4 on 2022-12-15 10:01
import taggit.managers

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import netbox_dns.fields.address
import taggit.managers
from django.db import migrations, models

import netbox_dns.fields.address
from netbox_dns.models import RecordTypeChoices
from netbox_dns.utilities import arpa_to_prefix


def fqdn(record):
if record.name == "@":
return f"{record.zone.name}."
else:
return f"{record.name}.{record.zone.name}."

return f"{record.name}.{record.zone.name}."


def address_from_name(record):
Expand Down
2 changes: 0 additions & 2 deletions netbox_dns/migrations/0022_search.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

from django.db import migrations


Expand Down
15 changes: 5 additions & 10 deletions netbox_dns/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@
from dns.rdtypes.ANY import SOA
from dns.exception import DNSException

from ipam.models import IPAddress

from django.core.validators import (
MinValueValidator,
MaxValueValidator,
)

from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import models, transaction
from django.db.models import Q, Max, ExpressionWrapper, BooleanField
from django.db.models.functions import Length
from django.urls import reverse

from django.db.models.signals import m2m_changed
from django.dispatch import receiver

from utilities.querysets import RestrictedQuerySet
from utilities.choices import ChoiceSet

from netbox.models import NetBoxModel
from netbox.search import SearchIndex, register_search
from utilities.querysets import RestrictedQuerySet
from utilities.choices import ChoiceSet
from extras.plugins.utils import get_plugin_config
from ipam.models import IPAddress

from netbox_dns.fields import NetworkField, AddressField
from netbox_dns.utilities import (
Expand All @@ -44,8 +41,6 @@
validate_extended_hostname,
)

from extras.plugins.utils import get_plugin_config


class NameServer(NetBoxModel):
name = models.CharField(
Expand Down Expand Up @@ -500,7 +495,7 @@ def clean(self, *args, **kwargs):
) from None

try:
soa_rname = dns_name.from_text(self.soa_rname, origin=dns_name.root)
dns_name.from_text(self.soa_rname, origin=dns_name.root)
validate_fqdn(self.soa_rname)
except (DNSException, ValidationError) as exc:
raise ValidationError(
Expand Down
4 changes: 1 addition & 3 deletions netbox_dns/template_content.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from django.db.models.functions import Length

from extras.plugins.utils import get_plugin_config
from extras.plugins import PluginTemplateExtension

from netbox_dns.models import Record, RecordTypeChoices, Zone, View, NameServer
from netbox_dns.models import Record, Zone, View, NameServer
from netbox_dns.tables import RelatedRecordTable


Expand Down
1 change: 0 additions & 1 deletion netbox_dns/tests/record/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def test_cname_and_nsec(self):

name1 = "test1"
name2 = "test2"
address = "fe80:dead:beef:1::42"

f_record1 = Record(
zone=f_zone,
Expand Down
1 change: 0 additions & 1 deletion netbox_dns/tests/zone/test_auto_ns.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def test_delete_ns_ns_record_removed(self):
)

def test_delete_soa_ns_exception(self):
zone = self.zone
nameserver = self.nameservers[0]

with self.assertRaisesRegexp(
Expand Down
3 changes: 0 additions & 3 deletions netbox_dns/tests/zone/test_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from utilities.testing import ViewTestCases
from utilities.testing import create_tags

from netbox_dns.tests.custom import ModelViewTestCase
from netbox_dns.models import NameServer, View, Zone, ZoneStatusChoices
Expand Down Expand Up @@ -52,8 +51,6 @@ def setUpTestData(cls):
)
Zone.objects.bulk_create(cls.zones)

tags = create_tags("Alpha", "Bravo", "Charlie")

cls.bulk_edit_data = {
"status": ZoneStatusChoices.STATUS_PARKED,
}
Expand Down
3 changes: 1 addition & 2 deletions netbox_dns/views/nameserver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dns import name as dns_name

from netbox.views import generic
from utilities.views import ViewTab, register_model_view

from netbox_dns.filters import NameServerFilter, ZoneFilter
from netbox_dns.forms import (
Expand All @@ -12,8 +13,6 @@
from netbox_dns.models import Zone, NameServer
from netbox_dns.tables import NameServerTable, ZoneTable

from utilities.views import ViewTab, register_model_view


class NameServerListView(generic.ObjectListView):
queryset = NameServer.objects.all()
Expand Down
4 changes: 2 additions & 2 deletions netbox_dns/views/view.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from utilities.views import ViewTab, register_model_view

from netbox.views import generic

from netbox_dns.models import View, Zone
from netbox_dns.filters import ViewFilter, ZoneFilter
from netbox_dns.forms import ViewForm, ViewFilterForm, ViewImportForm, ViewBulkEditForm
from netbox_dns.tables import ViewTable, ZoneTable

from utilities.views import ViewTab, register_model_view


class ViewView(generic.ObjectView):
queryset = View.objects.all().prefetch_related("zone_set")
Expand Down
2 changes: 0 additions & 2 deletions netbox_dns/views/zone.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from dns import name as dns_name

from django.urls import reverse

from netbox.views import generic
from utilities.views import ViewTab, register_model_view

Expand Down

0 comments on commit 16eda64

Please sign in to comment.