diff --git a/authentic2-ctl b/authentic2-ctl index 7ac5bfa43..fd677a96b 100755 --- a/authentic2-ctl +++ b/authentic2-ctl @@ -2,8 +2,6 @@ import os import sys -import authentic2.logger - if __name__ == "__main__": config_file = False diff --git a/doc/conf.py b/doc/conf.py index 961ffc73a..c2983371c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -11,8 +11,6 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os -import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/merge-coverage.py b/merge-coverage.py index 73034c834..0a2cda7af 100755 --- a/merge-coverage.py +++ b/merge-coverage.py @@ -7,7 +7,6 @@ import re import sys import xml.etree.ElementTree as ET from optparse import OptionParser -from shutil import copyfile ### This file came from the https://github.com/flow123d/flow123d repo they were nice enough to spend time to write this. ### It is copied here for other people to use on its own. diff --git a/src/authentic2/a2_rbac/management.py b/src/authentic2/a2_rbac/management.py index 8e288f4b4..7e5410b74 100644 --- a/src/authentic2/a2_rbac/management.py +++ b/src/authentic2/a2_rbac/management.py @@ -20,12 +20,10 @@ from django.utils.text import slugify from django.utils.translation import ugettext from django.utils.translation import ugettext_lazy as _ -from django_rbac.models import ADMIN_OP -from django_rbac.utils import get_ou_model, get_permission_model, get_role_model +from django_rbac.utils import get_ou_model, get_role_model from ..utils import get_fk_model from . import app_settings, utils -from .models import MANAGE_MEMBERS_OP def update_ou_admin_roles(ou): diff --git a/src/authentic2/api_views.py b/src/authentic2/api_views.py index 6e83b6161..4f0310fc9 100644 --- a/src/authentic2/api_views.py +++ b/src/authentic2/api_views.py @@ -56,7 +56,7 @@ from rest_framework.viewsets import ModelViewSet, ViewSet from authentic2.compat.drf import action from django_rbac.utils import get_ou_model, get_role_model -from . import api_mixins, app_settings, attribute_kinds, decorators, hooks, utils +from . import api_mixins, app_settings, decorators, hooks, utils from .a2_rbac.utils import get_default_ou from .custom_user.models import User from .journal_event_types import UserLogin, UserRegistration diff --git a/src/authentic2/apps/journal/utils.py b/src/authentic2/apps/journal/utils.py index 366a39d57..a5dbdee61 100644 --- a/src/authentic2/apps/journal/utils.py +++ b/src/authentic2/apps/journal/utils.py @@ -16,7 +16,7 @@ from datetime import date, timedelta -from django.db.models import DateField, Max, Min +from django.db.models import Max, Min def _json_value(value): diff --git a/src/authentic2/backends/ldap_backend.py b/src/authentic2/backends/ldap_backend.py index 0bd3d0cc1..a4a53aa42 100644 --- a/src/authentic2/backends/ldap_backend.py +++ b/src/authentic2/backends/ldap_backend.py @@ -24,7 +24,6 @@ try: from ldap.dn import escape_dn_chars from ldap.filter import filter_format from ldap.ldapobject import ReconnectLDAPObject as NativeLDAPObject - from pyasn1.codec.der import decoder PYTHON_LDAP3 = [int(x) for x in ldap.__version__.split('.')] >= [3] LDAPObject = NativeLDAPObject diff --git a/src/authentic2/compat/misc.py b/src/authentic2/compat/misc.py index 6f49db1ad..ed10196d0 100644 --- a/src/authentic2/compat/misc.py +++ b/src/authentic2/compat/misc.py @@ -15,7 +15,6 @@ # along with this program. If not, see . import inspect -from datetime import datetime from django.conf import settings diff --git a/src/authentic2/cors.py b/src/authentic2/cors.py index 25e67cc47..1064118dd 100644 --- a/src/authentic2/cors.py +++ b/src/authentic2/cors.py @@ -14,9 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import itertools -from django.apps import apps from django.conf import settings from django.utils.six.moves.urllib import parse as urlparse diff --git a/src/authentic2/custom_user/models.py b/src/authentic2/custom_user/models.py index a571bcbe5..bc67f99b4 100644 --- a/src/authentic2/custom_user/models.py +++ b/src/authentic2/custom_user/models.py @@ -20,7 +20,6 @@ from __future__ import unicode_literals import base64 import datetime import os -import random from django.core.exceptions import MultipleObjectsReturned, ValidationError from django.core.mail import send_mail @@ -38,7 +37,7 @@ from django.contrib.postgres.fields import JSONField from authentic2 import app_settings, utils from authentic2.decorators import RequestCache, errorcollector -from authentic2.models import Attribute, AttributeValue, Service, UserExternalId +from authentic2.models import Attribute, AttributeValue, Service from authentic2.validators import email_validator from django_rbac.models import PermissionMixin from django_rbac.utils import get_role_parenting_model diff --git a/src/authentic2/forms/honeypot.py b/src/authentic2/forms/honeypot.py index db51dc8b6..878131b5f 100644 --- a/src/authentic2/forms/honeypot.py +++ b/src/authentic2/forms/honeypot.py @@ -15,10 +15,7 @@ # along with this program. If not, see . -from django.core.exceptions import ValidationError from django.forms import BooleanField, CheckboxInput, Form -from django.utils.html import mark_safe -from django.utils.translation import gettext as _ class HoneypotInput(CheckboxInput): diff --git a/src/authentic2/forms/passwords.py b/src/authentic2/forms/passwords.py index e9d0a844c..dc233b873 100644 --- a/src/authentic2/forms/passwords.py +++ b/src/authentic2/forms/passwords.py @@ -22,12 +22,11 @@ from django.contrib.auth import forms as auth_forms from django.core.exceptions import ValidationError from django.db.models import Q from django.forms import Form -from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from .. import app_settings, hooks, models, utils from ..backends import get_user_queryset -from .fields import CheckPasswordField, NewPasswordField, PasswordField, ValidatedEmailField +from .fields import CheckPasswordField, NewPasswordField, PasswordField from .utils import NextUrlFormMixin logger = logging.getLogger(__name__) diff --git a/src/authentic2/forms/profile.py b/src/authentic2/forms/profile.py index ecf4f529e..e937767a1 100644 --- a/src/authentic2/forms/profile.py +++ b/src/authentic2/forms/profile.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from collections import OrderedDict from django import forms from django.forms.models import modelform_factory as dj_modelform_factory diff --git a/src/authentic2/manager/forms.py b/src/authentic2/manager/forms.py index a6d57e4cf..0f3220a20 100644 --- a/src/authentic2/manager/forms.py +++ b/src/authentic2/manager/forms.py @@ -23,13 +23,11 @@ from django import forms from django.contrib.auth import get_user_model from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError -from django.db.models.query import Q from django.utils import six from django.utils.text import slugify from django.utils.translation import pgettext, ugettext from django.utils.translation import ugettext_lazy as _ -from authentic2 import app_settings as a2_app_settings from authentic2.a2_rbac.utils import get_default_ou from authentic2.forms.fields import CheckPasswordField, NewPasswordField, ValidatedEmailField from authentic2.forms.profile import BaseUserForm diff --git a/src/authentic2/manager/user_import.py b/src/authentic2/manager/user_import.py index 8ef1f29cc..21ea4e6a5 100644 --- a/src/authentic2/manager/user_import.py +++ b/src/authentic2/manager/user_import.py @@ -31,7 +31,6 @@ from django.conf import settings from django.core.files.storage import default_storage from django.db import connection from django.utils import six -from django.utils.encoding import force_text from django.utils.functional import cached_property from django.utils.timezone import utc from django.utils.translation import ugettext_lazy as _ diff --git a/src/authentic2/manager/user_views.py b/src/authentic2/manager/user_views.py index f09f1334b..26155543a 100644 --- a/src/authentic2/manager/user_views.py +++ b/src/authentic2/manager/user_views.py @@ -26,7 +26,7 @@ from django.contrib.contenttypes.models import ContentType from django.core.exceptions import PermissionDenied from django.core.mail import EmailMultiAlternatives from django.db import models, transaction -from django.http import FileResponse, Http404, HttpResponseRedirect +from django.http import FileResponse, Http404 from django.shortcuts import get_object_or_404 from django.template import loader from django.urls import reverse, reverse_lazy diff --git a/src/authentic2/manager/widgets.py b/src/authentic2/manager/widgets.py index 319441b6f..e58d37b6e 100644 --- a/src/authentic2/manager/widgets.py +++ b/src/authentic2/manager/widgets.py @@ -24,9 +24,8 @@ from django.utils import six from django.utils.encoding import force_text from django_select2.forms import ModelSelect2MultipleWidget, ModelSelect2Widget -from authentic2.models import Service from authentic2_idp_oidc.models import OIDCAuthorization -from django_rbac.utils import get_ou_model, get_role_model +from django_rbac.utils import get_role_model from . import utils diff --git a/src/authentic2/managers.py b/src/authentic2/managers.py index 2a6b98219..b1844f072 100644 --- a/src/authentic2/managers.py +++ b/src/authentic2/managers.py @@ -19,7 +19,6 @@ from datetime import timedelta from django.conf import settings from django.contrib.contenttypes.models import ContentType -from django.contrib.postgres.search import SearchVector from django.db import models from django.db.models.query import QuerySet from django.utils.timezone import now diff --git a/src/authentic2/saml/common.py b/src/authentic2/saml/common.py index 84cc9dde9..133b1f48e 100644 --- a/src/authentic2/saml/common.py +++ b/src/authentic2/saml/common.py @@ -27,7 +27,6 @@ from django.shortcuts import render from django.urls import reverse from django.utils import six from django.utils.encoding import force_text -from django.utils.six.moves.urllib import parse as urlparse from authentic2.compat_lasso import lasso from authentic2.decorators import RequestCache diff --git a/src/authentic2/saml/models.py b/src/authentic2/saml/models.py index 4e2e80e1f..1b9931c51 100644 --- a/src/authentic2/saml/models.py +++ b/src/authentic2/saml/models.py @@ -30,7 +30,6 @@ from django.utils.encoding import force_str, force_text from django.utils.translation import ugettext_lazy as _ from authentic2.compat_lasso import lasso -from authentic2.utils import normalize_attribute_values try: from django.contrib.contenttypes.fields import GenericForeignKey diff --git a/src/authentic2/saml/saml2utils.py b/src/authentic2/saml/saml2utils.py index 156b47afb..580832304 100644 --- a/src/authentic2/saml/saml2utils.py +++ b/src/authentic2/saml/saml2utils.py @@ -16,8 +16,6 @@ from __future__ import print_function -import base64 -import binascii import collections import datetime import re diff --git a/src/authentic2/saml/x509utils.py b/src/authentic2/saml/x509utils.py index 89c14e45a..a1caddaed 100644 --- a/src/authentic2/saml/x509utils.py +++ b/src/authentic2/saml/x509utils.py @@ -15,7 +15,6 @@ # along with this program. If not, see . import base64 -import binascii import os import subprocess import tempfile diff --git a/src/authentic2/utils/__init__.py b/src/authentic2/utils/__init__.py index 4d49c292e..e92d7bdbc 100644 --- a/src/authentic2/utils/__init__.py +++ b/src/authentic2/utils/__init__.py @@ -16,8 +16,6 @@ import copy import ctypes -import datetime -import inspect import logging import random import time @@ -26,7 +24,6 @@ from functools import wraps from importlib import import_module from itertools import chain, count, islice -import django.apps from django import forms from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME @@ -34,7 +31,6 @@ from django.contrib.auth import authenticate as dj_authenticate from django.contrib.auth import get_user_model from django.contrib.auth import login as auth_login from django.core import signing -from django.core.cache import cache from django.core.exceptions import ImproperlyConfigured from django.core.mail import EmailMessage, send_mail from django.forms.utils import ErrorList, to_current_timezone @@ -45,11 +41,9 @@ from django.template.context import make_context from django.template.loader import TemplateDoesNotExist, render_to_string, select_template from django.urls import reverse from django.utils import html, six, timezone -from django.utils.encoding import force_bytes, iri_to_uri, uri_to_iri +from django.utils.encoding import iri_to_uri, uri_to_iri from django.utils.formats import localize -from django.utils.http import urlsafe_base64_encode from django.utils.six.moves.urllib import parse as urlparse -from django.utils.translation import ugettext as _ from django.utils.translation import ungettext try: diff --git a/src/authentic2/utils/lookups.py b/src/authentic2/utils/lookups.py index 27203cdfa..b7332c7dc 100644 --- a/src/authentic2/utils/lookups.py +++ b/src/authentic2/utils/lookups.py @@ -1,5 +1,4 @@ from django.contrib.postgres.lookups import Unaccent as PGUnaccent -from django.db.models import Func from django.db.models.functions import Concat from django.db.models.functions import ConcatPair as DjConcatPair diff --git a/src/authentic2/views.py b/src/authentic2/views.py index 18bc94c5d..43cebd19c 100644 --- a/src/authentic2/views.py +++ b/src/authentic2/views.py @@ -43,7 +43,6 @@ from django.template import loader from django.template.loader import render_to_string from django.urls import reverse from django.utils import six, timezone -from django.utils.http import urlsafe_base64_decode from django.utils.translation import ugettext as _ from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie diff --git a/src/authentic2_auth_oidc/models.py b/src/authentic2_auth_oidc/models.py index 669152f40..4e9820c6f 100644 --- a/src/authentic2_auth_oidc/models.py +++ b/src/authentic2_auth_oidc/models.py @@ -22,7 +22,7 @@ from django.contrib.postgres.fields import JSONField from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import ugettext_lazy as _ -from jwcrypto.jwk import JWK, InvalidJWKValue, JWKSet +from jwcrypto.jwk import InvalidJWKValue, JWKSet from django_rbac.utils import get_ou_model_name diff --git a/src/authentic2_idp_oidc/models.py b/src/authentic2_idp_oidc/models.py index f8e4bef98..aeb5a409d 100644 --- a/src/authentic2_idp_oidc/models.py +++ b/src/authentic2_idp_oidc/models.py @@ -23,7 +23,6 @@ from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.validators import URLValidator from django.db import models from django.utils import six -from django.utils.functional import cached_property from django.utils.six.moves.urllib import parse as urlparse from django.utils.timezone import now from django.utils.translation import ugettext_lazy as _ diff --git a/src/django_rbac/test_settings.py b/src/django_rbac/test_settings.py index d1d2a0fc0..641758bf8 100644 --- a/src/django_rbac/test_settings.py +++ b/src/django_rbac/test_settings.py @@ -1,5 +1,3 @@ -import os - from django.conf import global_settings MIDDLEWA_CLASSES = global_settings.MIDDLEWARE diff --git a/src/django_rbac/utils.py b/src/django_rbac/utils.py index 7aba5934b..96d030b48 100644 --- a/src/django_rbac/utils.py +++ b/src/django_rbac/utils.py @@ -2,7 +2,6 @@ import uuid from django.apps import apps from django.conf import settings -from django.utils import six from . import constants diff --git a/tests/test_a2_rbac.py b/tests/test_a2_rbac.py index 8e55e5bc9..275be0d71 100644 --- a/tests/test_a2_rbac.py +++ b/tests/test_a2_rbac.py @@ -22,7 +22,7 @@ from django.core.management import call_command from authentic2.a2_rbac.models import MANAGE_MEMBERS_OP from authentic2.a2_rbac.models import OrganizationalUnit as OU from authentic2.a2_rbac.models import Permission, Role, RoleAttribute -from authentic2.a2_rbac.utils import get_default_ou, get_view_user_perm +from authentic2.a2_rbac.utils import get_default_ou from authentic2.custom_user.models import User from authentic2.models import Service from authentic2.utils import get_hex_uuid diff --git a/tests/test_api.py b/tests/test_api.py index d75485858..31acdd148 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -30,9 +30,7 @@ from django.contrib.contenttypes.models import ContentType from django.core import mail from django.urls import reverse from django.utils.encoding import force_text -from django.utils.http import urlencode from django.utils.text import slugify -from django.utils.timezone import now from requests.models import Response from rest_framework import VERSION as drf_version diff --git a/tests/test_auth_saml.py b/tests/test_auth_saml.py index c57be706e..77df37408 100644 --- a/tests/test_auth_saml.py +++ b/tests/test_auth_saml.py @@ -14,14 +14,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import datetime import os import re import lasso import pytest from django.contrib.auth import get_user_model -from django.utils.timezone import now from mellon.models import UserSAMLIdentifier from authentic2.custom_user.models import DeletedUser diff --git a/tests/test_crypto.py b/tests/test_crypto.py index cd83c1747..3aa1fde93 100644 --- a/tests/test_crypto.py +++ b/tests/test_crypto.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import random -import time import uuid import pytest diff --git a/tests/test_custom_user.py b/tests/test_custom_user.py index 8750a85ff..d4de94d66 100644 --- a/tests/test_custom_user.py +++ b/tests/test_custom_user.py @@ -17,7 +17,6 @@ from datetime import date import pytest -from django.contrib.auth import get_user_model from authentic2.custom_user.models import DeletedUser, User from authentic2.models import Attribute diff --git a/tests/test_idp_saml2.py b/tests/test_idp_saml2.py index 9c2c25c4f..962eee4ff 100644 --- a/tests/test_idp_saml2.py +++ b/tests/test_idp_saml2.py @@ -34,14 +34,14 @@ from django.utils.encoding import force_bytes, force_str, force_text from django.utils.six.moves.urllib import parse as urlparse from django.utils.translation import gettext as _ -from authentic2.a2_rbac.models import OrganizationalUnit, Role, RoleAttribute +from authentic2.a2_rbac.models import OrganizationalUnit, Role from authentic2.constants import NONCE_FIELD_NAME, SERVICE_FIELD_NAME from authentic2.custom_user.models import User from authentic2.idp.saml import saml2_endpoints from authentic2.idp.saml.saml2_endpoints import get_extensions, get_login_hints_extension from authentic2.models import Attribute, Service from authentic2.saml import models as saml_models -from authentic2.saml.models import LibertyProvider, SAMLAttribute +from authentic2.saml.models import SAMLAttribute from authentic2.utils import make_url from . import utils diff --git a/tests/test_migrations.py b/tests/test_migrations.py index ed49e3d94..6855129c2 100644 --- a/tests/test_migrations.py +++ b/tests/test_migrations.py @@ -14,9 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import mock from django.contrib.auth.models import AbstractUser -from django.db.utils import ProgrammingError from django.utils.timezone import now diff --git a/tests/test_user_model.py b/tests/test_user_model.py index 27287d910..36c7fe017 100644 --- a/tests/test_user_model.py +++ b/tests/test_user_model.py @@ -20,7 +20,6 @@ import datetime import pytest from django.core import management from django.core.exceptions import ValidationError -from django.utils.timezone import now from authentic2.custom_user.models import DeletedUser, User from authentic2.models import Attribute, AttributeValue, UserExternalId diff --git a/tests/test_utils_lazy.py b/tests/test_utils_lazy.py index 737666b2c..c476d15bb 100644 --- a/tests/test_utils_lazy.py +++ b/tests/test_utils_lazy.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import pytest from authentic2.utils.lazy import lazy_join