Skip to content

Commit

Permalink
Merge pull request #3020 from Uninett/cleanup/add-noqa-to-necessary-u…
Browse files Browse the repository at this point in the history
…nused-imports

Mark needed, but marked as unused, imports and remove unused imports
  • Loading branch information
johannaengland authored Nov 22, 2024
2 parents 27b12b5 + afbe765 commit 518b252
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 11 deletions.
2 changes: 1 addition & 1 deletion python/nav/Snmp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

try:
# our highest preference is pynetsnmp, since it can support IPv6
import pynetsnmp
import pynetsnmp # noqa: F401 - needed to set BACKEND
except ImportError:
pass
else:
Expand Down
17 changes: 17 additions & 0 deletions python/nav/asyncdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@
from twisted.names.error import DNSServerError, DNSNameError
from twisted.names.error import DNSNotImplementedError, DNSQueryRefusedError

__all__ = [
"reverse_lookup",
"forward_lookup",
"Resolver",
"ForwardResolver",
"ReverseResolver",
"DNSUnknownError",
"DomainError",
"AuthoritativeDomainError",
"DNSQueryTimeoutError",
"DNSFormatError",
"DNSServerError",
"DNSNameError",
"DNSNotImplementedError",
"DNSQueryRefusedError",
]


BATCH_SIZE = 100

Expand Down
1 change: 0 additions & 1 deletion python/nav/bin/navcheckservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

from nav.logs import init_stderr_logging
from nav.statemon import checkermap
import nav.statemon.checker # necessary for relative imports on python3


_logger = logging.getLogger('nav.checkservice')
Expand Down
2 changes: 1 addition & 1 deletion python/nav/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def log_last_django_query(logger):
:param logger: The logging.Logger object to use for logging.
"""
from nav.models import manage as _manage
from nav.models import manage as _manage # noqa: F401 - import needed for debugging
from django.db import connection

if connection.queries:
Expand Down
32 changes: 32 additions & 0 deletions python/nav/ipdevpoll/shadows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,38 @@
from .prefix import Prefix
from .gwpeers import GatewayPeerSession

__all__ = [
"NetboxType",
"NetboxInfo",
"Vendor",
"Module",
"Device",
"Location",
"Room",
"Category",
"Organization",
"Usage",
"Vlan",
"GwPortPrefix",
"NetType",
"SwPortVlan",
"Arp",
"SwPortAllowedVlan",
"Sensor",
"PowerSupplyOrFan",
"POEPort",
"POEGroup",
"Interface",
"InterfaceStack",
"InterfaceAggregate",
"SwPortBlocked",
"Cam",
"AdjacencyCandidate",
"UnrecognizedNeighbor",
"NetboxEntity",
"GatewayPeerSession",
]

# Shadow classes. Not all of these will be used to store data, but
# may be used to retrieve and cache existing database records.

Expand Down
9 changes: 7 additions & 2 deletions python/nav/ipdevpoll/snmp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
#
"""selects a proper SNMP backend for ipdevpoll"""


try:
import pynetsnmp.twistedsnmp
import pynetsnmp.twistedsnmp # noqa: F401 - unused imports
except ImportError:
raise ImportError("No supported SNMP backend was found")
else:
from nav.ipdevpoll.snmp.pynetsnmp import AgentProxy, snmpprotocol

from .common import SnmpError

__all__ = [
"AgentProxy",
"snmpprotocol",
"SnmpError",
]
2 changes: 0 additions & 2 deletions python/nav/smsd/uninettmaildispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

from django.core.mail import EmailMessage

# pylint: disable=unused-import
from nav import models as _ # ensure Django is setup for NAV
from nav.smsd.dispatcher import Dispatcher, DispatcherError


Expand Down
2 changes: 1 addition & 1 deletion python/nav/web/geomap/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# is_nan must be available in the global namespace for the proper evaluation of
# some indicator rules
from nav.web.geomap.utils import union_dict, subdict, concat_list, is_nan
from nav.web.geomap.utils import union_dict, subdict, concat_list, is_nan # noqa: F401

_logger = logging.getLogger('nav.web.geomap.features')

Expand Down
6 changes: 3 additions & 3 deletions tests/unittests/web/ldapauth_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import importlib.util
import pytest

from nav.config import NAVConfigParser
from nav.web.auth.ldap import LDAPUser, open_ldap
from mock import Mock, patch

try:
import ldap
except ImportError:
found = importlib.util.find_spec('ldap')
if not found:
pytestmark = pytest.mark.skip(reason="ldap module is not available")


Expand Down

0 comments on commit 518b252

Please sign in to comment.