misc: remove some unused imports (#52457)

This commit is contained in:
Valentin Deniaud 2021-03-30 11:30:15 +02:00
parent 6c4aad3ab5
commit 8b506d4281
38 changed files with 12 additions and 61 deletions

View File

@ -2,8 +2,6 @@
import os import os
import sys import sys
import authentic2.logger
if __name__ == "__main__": if __name__ == "__main__":
config_file = False config_file = False

View File

@ -11,8 +11,6 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import os
import sys
# If extensions (or modules to document with autodoc) are in another directory, # 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 # add these directories to sys.path here. If the directory is relative to the

View File

@ -7,7 +7,6 @@ import re
import sys import sys
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from optparse import OptionParser 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. ### 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. ### It is copied here for other people to use on its own.

View File

@ -20,12 +20,10 @@ from django.utils.text import slugify
from django.utils.translation import ugettext from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django_rbac.models import ADMIN_OP from django_rbac.utils import get_ou_model, get_role_model
from django_rbac.utils import get_ou_model, get_permission_model, get_role_model
from ..utils import get_fk_model from ..utils import get_fk_model
from . import app_settings, utils from . import app_settings, utils
from .models import MANAGE_MEMBERS_OP
def update_ou_admin_roles(ou): def update_ou_admin_roles(ou):

View File

@ -56,7 +56,7 @@ from rest_framework.viewsets import ModelViewSet, ViewSet
from authentic2.compat.drf import action from authentic2.compat.drf import action
from django_rbac.utils import get_ou_model, get_role_model 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 .a2_rbac.utils import get_default_ou
from .custom_user.models import User from .custom_user.models import User
from .journal_event_types import UserLogin, UserRegistration from .journal_event_types import UserLogin, UserRegistration

View File

@ -16,7 +16,7 @@
from datetime import date, timedelta from datetime import date, timedelta
from django.db.models import DateField, Max, Min from django.db.models import Max, Min
def _json_value(value): def _json_value(value):

View File

@ -24,7 +24,6 @@ try:
from ldap.dn import escape_dn_chars from ldap.dn import escape_dn_chars
from ldap.filter import filter_format from ldap.filter import filter_format
from ldap.ldapobject import ReconnectLDAPObject as NativeLDAPObject from ldap.ldapobject import ReconnectLDAPObject as NativeLDAPObject
from pyasn1.codec.der import decoder
PYTHON_LDAP3 = [int(x) for x in ldap.__version__.split('.')] >= [3] PYTHON_LDAP3 = [int(x) for x in ldap.__version__.split('.')] >= [3]
LDAPObject = NativeLDAPObject LDAPObject = NativeLDAPObject

View File

@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import inspect import inspect
from datetime import datetime
from django.conf import settings from django.conf import settings

View File

@ -14,9 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import itertools
from django.apps import apps
from django.conf import settings from django.conf import settings
from django.utils.six.moves.urllib import parse as urlparse from django.utils.six.moves.urllib import parse as urlparse

View File

@ -20,7 +20,6 @@ from __future__ import unicode_literals
import base64 import base64
import datetime import datetime
import os import os
import random
from django.core.exceptions import MultipleObjectsReturned, ValidationError from django.core.exceptions import MultipleObjectsReturned, ValidationError
from django.core.mail import send_mail 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 import app_settings, utils
from authentic2.decorators import RequestCache, errorcollector 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 authentic2.validators import email_validator
from django_rbac.models import PermissionMixin from django_rbac.models import PermissionMixin
from django_rbac.utils import get_role_parenting_model from django_rbac.utils import get_role_parenting_model

View File

@ -15,10 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.core.exceptions import ValidationError
from django.forms import BooleanField, CheckboxInput, Form from django.forms import BooleanField, CheckboxInput, Form
from django.utils.html import mark_safe
from django.utils.translation import gettext as _
class HoneypotInput(CheckboxInput): class HoneypotInput(CheckboxInput):

View File

@ -22,12 +22,11 @@ from django.contrib.auth import forms as auth_forms
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db.models import Q from django.db.models import Q
from django.forms import Form from django.forms import Form
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from .. import app_settings, hooks, models, utils from .. import app_settings, hooks, models, utils
from ..backends import get_user_queryset from ..backends import get_user_queryset
from .fields import CheckPasswordField, NewPasswordField, PasswordField, ValidatedEmailField from .fields import CheckPasswordField, NewPasswordField, PasswordField
from .utils import NextUrlFormMixin from .utils import NextUrlFormMixin
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from collections import OrderedDict
from django import forms from django import forms
from django.forms.models import modelform_factory as dj_modelform_factory from django.forms.models import modelform_factory as dj_modelform_factory

View File

@ -23,13 +23,11 @@ from django import forms
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db.models.query import Q
from django.utils import six from django.utils import six
from django.utils.text import slugify from django.utils.text import slugify
from django.utils.translation import pgettext, ugettext from django.utils.translation import pgettext, ugettext
from django.utils.translation import ugettext_lazy as _ 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.a2_rbac.utils import get_default_ou
from authentic2.forms.fields import CheckPasswordField, NewPasswordField, ValidatedEmailField from authentic2.forms.fields import CheckPasswordField, NewPasswordField, ValidatedEmailField
from authentic2.forms.profile import BaseUserForm from authentic2.forms.profile import BaseUserForm

View File

@ -31,7 +31,6 @@ from django.conf import settings
from django.core.files.storage import default_storage from django.core.files.storage import default_storage
from django.db import connection from django.db import connection
from django.utils import six from django.utils import six
from django.utils.encoding import force_text
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.timezone import utc from django.utils.timezone import utc
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _

View File

@ -26,7 +26,7 @@ from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.core.mail import EmailMultiAlternatives from django.core.mail import EmailMultiAlternatives
from django.db import models, transaction 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.shortcuts import get_object_or_404
from django.template import loader from django.template import loader
from django.urls import reverse, reverse_lazy from django.urls import reverse, reverse_lazy

View File

@ -24,9 +24,8 @@ from django.utils import six
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django_select2.forms import ModelSelect2MultipleWidget, ModelSelect2Widget from django_select2.forms import ModelSelect2MultipleWidget, ModelSelect2Widget
from authentic2.models import Service
from authentic2_idp_oidc.models import OIDCAuthorization 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 from . import utils

View File

@ -19,7 +19,6 @@ from datetime import timedelta
from django.conf import settings from django.conf import settings
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.search import SearchVector
from django.db import models from django.db import models
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django.utils.timezone import now from django.utils.timezone import now

View File

@ -27,7 +27,6 @@ from django.shortcuts import render
from django.urls import reverse from django.urls import reverse
from django.utils import six from django.utils import six
from django.utils.encoding import force_text 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.compat_lasso import lasso
from authentic2.decorators import RequestCache from authentic2.decorators import RequestCache

View File

@ -30,7 +30,6 @@ from django.utils.encoding import force_str, force_text
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from authentic2.compat_lasso import lasso from authentic2.compat_lasso import lasso
from authentic2.utils import normalize_attribute_values
try: try:
from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.fields import GenericForeignKey

View File

@ -16,8 +16,6 @@
from __future__ import print_function from __future__ import print_function
import base64
import binascii
import collections import collections
import datetime import datetime
import re import re

View File

@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import base64 import base64
import binascii
import os import os
import subprocess import subprocess
import tempfile import tempfile

View File

@ -16,8 +16,6 @@
import copy import copy
import ctypes import ctypes
import datetime
import inspect
import logging import logging
import random import random
import time import time
@ -26,7 +24,6 @@ from functools import wraps
from importlib import import_module from importlib import import_module
from itertools import chain, count, islice from itertools import chain, count, islice
import django.apps
from django import forms from django import forms
from django.conf import settings from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME 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 get_user_model
from django.contrib.auth import login as auth_login from django.contrib.auth import login as auth_login
from django.core import signing from django.core import signing
from django.core.cache import cache
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.core.mail import EmailMessage, send_mail from django.core.mail import EmailMessage, send_mail
from django.forms.utils import ErrorList, to_current_timezone 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.template.loader import TemplateDoesNotExist, render_to_string, select_template
from django.urls import reverse from django.urls import reverse
from django.utils import html, six, timezone 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.formats import localize
from django.utils.http import urlsafe_base64_encode
from django.utils.six.moves.urllib import parse as urlparse from django.utils.six.moves.urllib import parse as urlparse
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext from django.utils.translation import ungettext
try: try:

View File

@ -1,5 +1,4 @@
from django.contrib.postgres.lookups import Unaccent as PGUnaccent 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 Concat
from django.db.models.functions import ConcatPair as DjConcatPair from django.db.models.functions import ConcatPair as DjConcatPair

View File

@ -43,7 +43,6 @@ from django.template import loader
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.urls import reverse from django.urls import reverse
from django.utils import six, timezone from django.utils import six, timezone
from django.utils.http import urlsafe_base64_decode
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators.cache import never_cache from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie

View File

@ -22,7 +22,7 @@ from django.contrib.postgres.fields import JSONField
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ 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 from django_rbac.utils import get_ou_model_name

View File

@ -23,7 +23,6 @@ from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.validators import URLValidator from django.core.validators import URLValidator
from django.db import models from django.db import models
from django.utils import six 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.six.moves.urllib import parse as urlparse
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _

View File

@ -1,5 +1,3 @@
import os
from django.conf import global_settings from django.conf import global_settings
MIDDLEWA_CLASSES = global_settings.MIDDLEWARE MIDDLEWA_CLASSES = global_settings.MIDDLEWARE

View File

@ -2,7 +2,6 @@ import uuid
from django.apps import apps from django.apps import apps
from django.conf import settings from django.conf import settings
from django.utils import six
from . import constants from . import constants

View File

@ -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 MANAGE_MEMBERS_OP
from authentic2.a2_rbac.models import OrganizationalUnit as OU from authentic2.a2_rbac.models import OrganizationalUnit as OU
from authentic2.a2_rbac.models import Permission, Role, RoleAttribute 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.custom_user.models import User
from authentic2.models import Service from authentic2.models import Service
from authentic2.utils import get_hex_uuid from authentic2.utils import get_hex_uuid

View File

@ -30,9 +30,7 @@ from django.contrib.contenttypes.models import ContentType
from django.core import mail from django.core import mail
from django.urls import reverse from django.urls import reverse
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.http import urlencode
from django.utils.text import slugify from django.utils.text import slugify
from django.utils.timezone import now
from requests.models import Response from requests.models import Response
from rest_framework import VERSION as drf_version from rest_framework import VERSION as drf_version

View File

@ -14,14 +14,12 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import datetime
import os import os
import re import re
import lasso import lasso
import pytest import pytest
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.utils.timezone import now
from mellon.models import UserSAMLIdentifier from mellon.models import UserSAMLIdentifier
from authentic2.custom_user.models import DeletedUser from authentic2.custom_user.models import DeletedUser

View File

@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import random import random
import time
import uuid import uuid
import pytest import pytest

View File

@ -17,7 +17,6 @@
from datetime import date from datetime import date
import pytest import pytest
from django.contrib.auth import get_user_model
from authentic2.custom_user.models import DeletedUser, User from authentic2.custom_user.models import DeletedUser, User
from authentic2.models import Attribute from authentic2.models import Attribute

View File

@ -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.six.moves.urllib import parse as urlparse
from django.utils.translation import gettext as _ 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.constants import NONCE_FIELD_NAME, SERVICE_FIELD_NAME
from authentic2.custom_user.models import User from authentic2.custom_user.models import User
from authentic2.idp.saml import saml2_endpoints from authentic2.idp.saml import saml2_endpoints
from authentic2.idp.saml.saml2_endpoints import get_extensions, get_login_hints_extension from authentic2.idp.saml.saml2_endpoints import get_extensions, get_login_hints_extension
from authentic2.models import Attribute, Service from authentic2.models import Attribute, Service
from authentic2.saml import models as saml_models 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 authentic2.utils import make_url
from . import utils from . import utils

View File

@ -14,9 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import mock
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
from django.db.utils import ProgrammingError
from django.utils.timezone import now from django.utils.timezone import now

View File

@ -20,7 +20,6 @@ import datetime
import pytest import pytest
from django.core import management from django.core import management
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.timezone import now
from authentic2.custom_user.models import DeletedUser, User from authentic2.custom_user.models import DeletedUser, User
from authentic2.models import Attribute, AttributeValue, UserExternalId from authentic2.models import Attribute, AttributeValue, UserExternalId

View File

@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest
from authentic2.utils.lazy import lazy_join from authentic2.utils.lazy import lazy_join