diff --git a/python/nav/Snmp/__init__.py b/python/nav/Snmp/__init__.py index 83097c6076..df0d7daaab 100644 --- a/python/nav/Snmp/__init__.py +++ b/python/nav/Snmp/__init__.py @@ -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: diff --git a/python/nav/asyncdns.py b/python/nav/asyncdns.py index 3280560323..9f803c3a6b 100644 --- a/python/nav/asyncdns.py +++ b/python/nav/asyncdns.py @@ -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 diff --git a/python/nav/bin/navcheckservice.py b/python/nav/bin/navcheckservice.py index 5a27107953..3aa6cb08f7 100755 --- a/python/nav/bin/navcheckservice.py +++ b/python/nav/bin/navcheckservice.py @@ -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') diff --git a/python/nav/debug.py b/python/nav/debug.py index 2c68569ea8..383079c06f 100644 --- a/python/nav/debug.py +++ b/python/nav/debug.py @@ -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: diff --git a/python/nav/ipdevpoll/shadows/__init__.py b/python/nav/ipdevpoll/shadows/__init__.py index a231239f5f..69ceb53d8b 100644 --- a/python/nav/ipdevpoll/shadows/__init__.py +++ b/python/nav/ipdevpoll/shadows/__init__.py @@ -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. diff --git a/python/nav/ipdevpoll/snmp/__init__.py b/python/nav/ipdevpoll/snmp/__init__.py index 01020a2ff6..f6fadd9e43 100644 --- a/python/nav/ipdevpoll/snmp/__init__.py +++ b/python/nav/ipdevpoll/snmp/__init__.py @@ -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", +] diff --git a/python/nav/smsd/uninettmaildispatcher.py b/python/nav/smsd/uninettmaildispatcher.py index d36aacbf71..e5778c93dc 100644 --- a/python/nav/smsd/uninettmaildispatcher.py +++ b/python/nav/smsd/uninettmaildispatcher.py @@ -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 diff --git a/python/nav/web/geomap/features.py b/python/nav/web/geomap/features.py index 9e749d0980..0324d17410 100644 --- a/python/nav/web/geomap/features.py +++ b/python/nav/web/geomap/features.py @@ -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') diff --git a/tests/unittests/web/ldapauth_test.py b/tests/unittests/web/ldapauth_test.py index 6833ee086a..070140e999 100644 --- a/tests/unittests/web/ldapauth_test.py +++ b/tests/unittests/web/ldapauth_test.py @@ -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")