misc: fix import-error pylint error (#56982)

This commit is contained in:
Valentin Deniaud 2021-09-20 15:31:43 +02:00
parent 3e5fc8a898
commit 9d7aa5d839
7 changed files with 12 additions and 10 deletions

View File

@ -42,8 +42,8 @@ except ImportError:
MULTITENANT = 'hobo.multitenant' in settings.INSTALLED_APPS
if MULTITENANT:
from hobo.multitenant.middleware import TenantMiddleware
from tenant_schemas.utils import tenant_context
from hobo.multitenant.middleware import TenantMiddleware # pylint: disable=import-error
from tenant_schemas.utils import tenant_context # pylint: disable=import-error
class FakeState:

View File

@ -198,6 +198,7 @@ class Report:
def publik_provisionning():
if 'hobo.agent.authentic2' in settings.INSTALLED_APPS and not simulate:
# provisionning is initialied in hobo.agent.authentic2.provisionning.apps
# pylint: disable=import-error
from hobo.agent.authentic2.provisionning import provisionning as engine
with engine:

View File

@ -102,11 +102,11 @@ def accept_nonce_file_storage(path, now, value, context=None, not_on_or_after=No
def accept_nonce_model(now, value, context=None, not_on_or_after=None):
import models
from authentic2.nonce.models import Nonce
if not_on_or_after:
not_on_or_after = compute_not_on_or_after(now, not_on_or_after)
nonce, created = models.Nonce.objects.get_or_create(value=value, context=context)
nonce, created = Nonce.objects.get_or_create(value=value, context=context)
if created or (nonce.not_on_or_after and nonce.not_on_or_after < now):
nonce.not_on_or_after = not_on_or_after
nonce.save()
@ -142,12 +142,12 @@ def cleanup_nonces(now=None):
a datetime value to define what is the current time, if None is
given, datetime.now() is used. It can be used for unit testing.
"""
import models
from authentic2.nonce.models import Nonce
now = now or dt.datetime.now()
mode = getattr(settings, 'NONCE_STORAGE', STORAGE_MODEL)
# the model always exists, so we always clean it
models.Nonce.objects.cleanup(now)
Nonce.objects.cleanup(now)
if mode == STORAGE_MODEL:
pass
if mode.startswith(STORAGE_FILESYSTEM):

View File

@ -130,7 +130,7 @@ if settings.DEBUG:
urlpatterns += [url(r'^media/(?P<path>.*)$', media_serve, {'document_root': settings.MEDIA_ROOT})]
if settings.DEBUG and 'debug_toolbar' in settings.INSTALLED_APPS:
import debug_toolbar
import debug_toolbar # pylint: disable=import-error
urlpatterns = [
url(r'^__debug__/', include(debug_toolbar.urls)),

View File

@ -44,8 +44,8 @@ def ensure_db(func):
@contextlib.contextmanager
def tenant_context(domain):
from hobo.multitenant.middleware import TenantMiddleware
from tenant_schemas.utils import tenant_context
from hobo.multitenant.middleware import TenantMiddleware # pylint: disable=import-error
from tenant_schemas.utils import tenant_context # pylint: disable=import-error
tenant = TenantMiddleware.get_tenant_by_hostname(domain)
with tenant_context(tenant):

View File

@ -27,7 +27,7 @@ from django.urls import reverse
from django.utils.http import urlencode
from django.utils.translation import ugettext_lazy as _
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from requests.packages.urllib3.util.retry import Retry # pylint: disable=import-error
from . import app_settings

View File

@ -68,6 +68,7 @@ deps =
faker
pylint
pylint-django
uwsgidecorators
enum34<=1.1.6
ldaptools>=0.15
oldldap: python-ldap<3