From 9a2f36ae54b13e902d4a40f1aaa7901e0cd63bd7 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Mon, 20 Sep 2021 15:31:43 +0200 Subject: [PATCH 19/59] misc: fix import-error pylint error (#56982) --- src/authentic2/management/commands/check-and-repair.py | 4 ++-- src/authentic2/manager/user_import.py | 1 + src/authentic2/nonce/utils.py | 8 ++++---- src/authentic2/urls.py | 2 +- src/authentic2/utils/spooler.py | 4 ++-- src/authentic2_auth_fc/utils.py | 2 +- tox.ini | 1 + 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/authentic2/management/commands/check-and-repair.py b/src/authentic2/management/commands/check-and-repair.py index 2bc2acc8..15f42c93 100644 --- a/src/authentic2/management/commands/check-and-repair.py +++ b/src/authentic2/management/commands/check-and-repair.py @@ -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: diff --git a/src/authentic2/manager/user_import.py b/src/authentic2/manager/user_import.py index 321a67cd..89bb794d 100644 --- a/src/authentic2/manager/user_import.py +++ b/src/authentic2/manager/user_import.py @@ -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: diff --git a/src/authentic2/nonce/utils.py b/src/authentic2/nonce/utils.py index e5a68415..3e8f9373 100644 --- a/src/authentic2/nonce/utils.py +++ b/src/authentic2/nonce/utils.py @@ -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): diff --git a/src/authentic2/urls.py b/src/authentic2/urls.py index 67e56504..4276f377 100644 --- a/src/authentic2/urls.py +++ b/src/authentic2/urls.py @@ -130,7 +130,7 @@ if settings.DEBUG: urlpatterns += [url(r'^media/(?P.*)$', 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)), diff --git a/src/authentic2/utils/spooler.py b/src/authentic2/utils/spooler.py index be69ba31..2814b0fb 100644 --- a/src/authentic2/utils/spooler.py +++ b/src/authentic2/utils/spooler.py @@ -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): diff --git a/src/authentic2_auth_fc/utils.py b/src/authentic2_auth_fc/utils.py index b795a313..d73a6c58 100644 --- a/src/authentic2_auth_fc/utils.py +++ b/src/authentic2_auth_fc/utils.py @@ -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 diff --git a/tox.ini b/tox.ini index c3be5c47..8eb3f95b 100644 --- a/tox.ini +++ b/tox.ini @@ -68,6 +68,7 @@ deps = faker pylint pylint-django + uwsgidecorators enum34<=1.1.6 ldaptools>=0.15 oldldap: python-ldap<3 -- 2.30.2