From c71299d053972072add7fe245f9c91b0c3952fe1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Thu, 1 Apr 2021 18:39:36 +0200
Subject: [PATCH 02/18] misc: pylint fix unused-import (#52630)

---
 tests/admin_pages/test_block.py      |  5 -----
 tests/admin_pages/test_datasource.py |  6 ------
 tests/admin_pages/test_settings.py   |  2 +-
 tests/admin_pages/test_workflow.py   |  6 ------
 tests/api/test_utils.py              |  2 +-
 tests/test_convert_to_sql.py         |  1 -
 tests/test_ctl.py                    |  4 ----
 tests/test_ezt.py                    |  2 +-
 tests/test_formdef.py                | 24 ++++++++----------------
 tests/test_hobo.py                   |  1 -
 tests/test_misc.py                   |  5 ++---
 tests/test_publisher.py              |  3 ---
 tests/test_register.py               |  2 --
 tests/test_rootdirectory.py          |  3 ---
 tests/test_saml_auth.py              |  6 +++---
 tests/test_sessions.py               |  1 -
 tests/test_sql.py                    |  8 +-------
 tests/test_templates.py              |  7 +++----
 tests/test_texts.py                  |  1 -
 tests/test_upload_storage.py         |  1 -
 tests/test_users.py                  |  7 +------
 tests/test_workflows.py              |  1 -
 22 files changed, 21 insertions(+), 77 deletions(-)

diff --git a/tests/admin_pages/test_block.py b/tests/admin_pages/test_block.py
index 81502515..b8c2de48 100644
--- a/tests/admin_pages/test_block.py
+++ b/tests/admin_pages/test_block.py
@@ -2,11 +2,6 @@
 
 import re
 
-try:
-    import lasso
-except ImportError:
-    lasso = None
-
 import pytest
 from webtest import Upload
 
diff --git a/tests/admin_pages/test_datasource.py b/tests/admin_pages/test_datasource.py
index 20a708c0..3f83cd63 100644
--- a/tests/admin_pages/test_datasource.py
+++ b/tests/admin_pages/test_datasource.py
@@ -6,12 +6,6 @@ import os
 import xml.etree.ElementTree as ET
 
 import mock
-
-try:
-    import lasso
-except ImportError:
-    lasso = None
-
 import pytest
 from webtest import Upload
 
diff --git a/tests/admin_pages/test_settings.py b/tests/admin_pages/test_settings.py
index 2f94a2c7..ff81a7c2 100644
--- a/tests/admin_pages/test_settings.py
+++ b/tests/admin_pages/test_settings.py
@@ -7,7 +7,7 @@ import urllib.parse
 import zipfile
 
 try:
-    import lasso
+    import lasso  # pylint: disable=unused-import
 except ImportError:
     lasso = None
 
diff --git a/tests/admin_pages/test_workflow.py b/tests/admin_pages/test_workflow.py
index 601d667d..8b0d18e3 100644
--- a/tests/admin_pages/test_workflow.py
+++ b/tests/admin_pages/test_workflow.py
@@ -5,12 +5,6 @@ import os
 import re
 
 import mock
-
-try:
-    import lasso
-except ImportError:
-    lasso = None
-
 import pytest
 from quixote.http_request import Upload as QuixoteUpload
 from webtest import Upload
diff --git a/tests/api/test_utils.py b/tests/api/test_utils.py
index 9c91bb41..41c361e8 100644
--- a/tests/api/test_utils.py
+++ b/tests/api/test_utils.py
@@ -1,5 +1,5 @@
 import pytest
-from quixote import cleanup, get_response
+from quixote import cleanup
 
 from wcs import sessions
 from wcs.api_utils import get_query_flag
diff --git a/tests/test_convert_to_sql.py b/tests/test_convert_to_sql.py
index 3aaa40af..cf9b0ea3 100644
--- a/tests/test_convert_to_sql.py
+++ b/tests/test_convert_to_sql.py
@@ -1,4 +1,3 @@
-import collections
 import os
 import random
 
diff --git a/tests/test_ctl.py b/tests/test_ctl.py
index b2dab8de..840abe24 100644
--- a/tests/test_ctl.py
+++ b/tests/test_ctl.py
@@ -1,8 +1,6 @@
 import collections
 import os
 import sys
-from email.mime.multipart import MIMEMultipart
-from email.mime.text import MIMEText
 
 import psycopg2
 import pytest
@@ -10,7 +8,6 @@ from django.core.management import CommandError, call_command
 
 import wcs.qommon.ctl
 from wcs.ctl.delete_tenant import CmdDeleteTenant
-from wcs.ctl.management.commands.runscript import Command as CmdRunScript
 from wcs.ctl.management.commands.trigger_jumps import select_and_jump_formdata
 from wcs.ctl.rebuild_indexes import rebuild_vhost_indexes
 from wcs.ctl.wipe_data import CmdWipeData
@@ -18,7 +15,6 @@ from wcs.fields import EmailField, StringField
 from wcs.formdef import FormDef
 from wcs.qommon.afterjobs import AfterJob
 from wcs.qommon.management.commands.collectstatic import Command as CmdCollectStatic
-from wcs.qommon.management.commands.makemessages import Command as CmdMakeMessages
 from wcs.qommon.management.commands.migrate import Command as CmdMigrate
 from wcs.qommon.management.commands.migrate_schemas import Command as CmdMigrateSchemas
 from wcs.sql import cleanup_connection, get_connection_and_cursor
diff --git a/tests/test_ezt.py b/tests/test_ezt.py
index 4756b7fa..1cf2b288 100644
--- a/tests/test_ezt.py
+++ b/tests/test_ezt.py
@@ -15,7 +15,7 @@ from wcs.qommon.ezt import (
 )
 from wcs.scripts import ScriptsSubstitutionProxy
 
-from .utilities import clean_temporary_pub, create_temporary_pub, get_app
+from .utilities import clean_temporary_pub, create_temporary_pub
 
 
 def setup_module(module):
diff --git a/tests/test_formdef.py b/tests/test_formdef.py
index c89f9fbf..bc369b00 100644
--- a/tests/test_formdef.py
+++ b/tests/test_formdef.py
@@ -4,22 +4,26 @@ import io
 import json
 import os
 import pickle
-import shutil
-import sys
 import time
 
 import pytest
 from django.utils.encoding import force_bytes
-from quixote import cleanup
 
 from wcs import fields
+from wcs.admin.settings import UserFieldsFormDef
 from wcs.blocks import BlockDef
+from wcs.carddef import CardDef
 from wcs.fields import DateField, FileField, ItemField, PageField, StringField
 from wcs.formdef import FormDef, get_formdefs_of_all_kinds
 from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.upload_storage import PicklableUpload
 from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
-from wcs.workflows import AttachmentEvolutionPart, Workflow, WorkflowBackofficeFieldsFormDef
+from wcs.workflows import (
+    AttachmentEvolutionPart,
+    Workflow,
+    WorkflowBackofficeFieldsFormDef,
+    WorkflowVariablesFieldsFormDef,
+)
 
 from .utilities import clean_temporary_pub, create_temporary_pub
 
@@ -135,8 +139,6 @@ def test_substitution_variables(pub):
     formdef.name = 'foo'
     formdef.store()
 
-    from wcs.workflows import WorkflowVariablesFieldsFormDef
-
     wf = Workflow(name='variables')
     wf.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=wf)
     wf.variables_formdef.fields = [
@@ -176,8 +178,6 @@ def test_schema_with_date_variable(pub):
     formdef.name = 'foo'
     formdef.store()
 
-    from wcs.workflows import WorkflowVariablesFieldsFormDef
-
     wf = Workflow(name='variables')
     wf.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=wf)
     wf.variables_formdef.fields.append(DateField(label='Test', type='date', varname='foo'))
@@ -363,7 +363,6 @@ def test_unused_file_removal_job(pub):
 
         # file referenced in formdef option
         workflow = Workflow(name='variables')
-        from wcs.workflows import WorkflowVariablesFieldsFormDef
 
         workflow.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=workflow)
         workflow.variables_formdef.fields.append(fields.FileField(id='1', label='Test', type='file'))
@@ -449,8 +448,6 @@ def test_unused_file_removal_job(pub):
 
         # files in user profile
 
-        from wcs.admin.settings import UserFieldsFormDef
-
         user_formdef = UserFieldsFormDef(pub)
         user_formdef.fields.append(fields.FileField(id='3', label='test', type='file'))
         user_formdef.store()
@@ -494,11 +491,6 @@ def test_unused_file_removal_job(pub):
 
 
 def test_get_formdefs_of_all_kinds(pub):
-    from wcs.admin.settings import UserFieldsFormDef
-    from wcs.carddef import CardDef
-    from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
-    from wcs.workflows import WorkflowBackofficeFieldsFormDef, WorkflowVariablesFieldsFormDef
-
     BlockDef.wipe()
     FormDef.wipe()
     Workflow.wipe()
diff --git a/tests/test_hobo.py b/tests/test_hobo.py
index b0fee029..f162941e 100644
--- a/tests/test_hobo.py
+++ b/tests/test_hobo.py
@@ -10,7 +10,6 @@ import tempfile
 import urllib.parse
 
 import mock
-import pytest
 from quixote import cleanup
 
 from wcs import fields, sql
diff --git a/tests/test_misc.py b/tests/test_misc.py
index f6ec8e5a..358cd676 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -4,7 +4,6 @@ import base64
 import datetime
 import json
 import os
-import pickle
 import pwd
 import re
 import socket
@@ -22,7 +21,7 @@ from wcs.admin.settings import FileTypesDirectory
 from wcs.fields import StringField
 from wcs.qommon import evalutils, force_str
 from wcs.qommon.backoffice.listing import pagination_links
-from wcs.qommon.emails import docutils
+from wcs.qommon.emails import docutils  # noqa pylint: disable=unused-import
 from wcs.qommon.emails import email as send_email
 from wcs.qommon.form import FileSizeWidget
 from wcs.qommon.http_request import HTTPRequest
@@ -738,4 +737,4 @@ ii  wcs            5.71-1~eob100+1 all          web application to design and se
 
 def test_uwsgi_spooler_import():
     with pytest.raises(ImportError):
-        import wcs.qommon.spooler
+        import wcs.qommon.spooler  # noqa pylint: disable=unused-import
diff --git a/tests/test_publisher.py b/tests/test_publisher.py
index fd096aaa..001d52b1 100644
--- a/tests/test_publisher.py
+++ b/tests/test_publisher.py
@@ -4,7 +4,6 @@ import os
 import pickle
 import re
 import shutil
-import stat
 import sys
 import tempfile
 import time
@@ -12,12 +11,10 @@ import zipfile
 
 import mock
 import pytest
-from django.conf import settings
 from django.core.management import call_command
 from django.core.management.base import CommandError
 from django.http import Http404
 from django.test import override_settings
-from django.utils.encoding import force_text
 from quixote import cleanup
 
 from wcs.qommon import get_publisher_class
diff --git a/tests/test_register.py b/tests/test_register.py
index 430b5413..14b8d6da 100644
--- a/tests/test_register.py
+++ b/tests/test_register.py
@@ -2,10 +2,8 @@
 
 import hashlib
 import re
-import shutil
 
 import pytest
-from quixote import cleanup
 
 from wcs.qommon import force_str
 from wcs.qommon.http_request import HTTPRequest
diff --git a/tests/test_rootdirectory.py b/tests/test_rootdirectory.py
index decb65d9..efb4ec5a 100644
--- a/tests/test_rootdirectory.py
+++ b/tests/test_rootdirectory.py
@@ -1,12 +1,9 @@
-import os
 import shutil
-import sys
 
 import pytest
 from quixote import cleanup
 
 import wcs.forms.root
-from wcs import formdef
 from wcs.categories import Category
 from wcs.formdef import FormDef
 from wcs.qommon import sessions
diff --git a/tests/test_saml_auth.py b/tests/test_saml_auth.py
index 59b837a0..56328499 100644
--- a/tests/test_saml_auth.py
+++ b/tests/test_saml_auth.py
@@ -11,12 +11,12 @@ except ImportError:
     lasso = None
 
 import pytest
-from quixote import cleanup, get_session, get_session_manager
+from quixote import get_session_manager
 from quixote.errors import RequestError
 
-from wcs.qommon import sessions, x509utils
+from wcs.qommon import x509utils
 from wcs.qommon.http_request import HTTPRequest
-from wcs.qommon.ident.idp import AdminIDPDir, MethodAdminDirectory
+from wcs.qommon.ident.idp import MethodAdminDirectory
 from wcs.qommon.misc import get_lasso_server
 from wcs.qommon.saml2 import Saml2Directory
 
diff --git a/tests/test_sessions.py b/tests/test_sessions.py
index f2bc8488..d69f333b 100644
--- a/tests/test_sessions.py
+++ b/tests/test_sessions.py
@@ -4,7 +4,6 @@ import shutil
 import time
 
 import pytest
-from quixote import cleanup
 
 from wcs import fields
 from wcs.formdef import FormDef
diff --git a/tests/test_sql.py b/tests/test_sql.py
index 73708450..96c15183 100644
--- a/tests/test_sql.py
+++ b/tests/test_sql.py
@@ -1,21 +1,15 @@
-# -*- coding: utf-8 -*-
-
 from __future__ import print_function
 
 import datetime
-import os
 import random
-import shutil
 import string
-import sys
 import time
 
 import pytest
-from django.core.management import call_command
 from quixote import cleanup
 
 import wcs.qommon.storage as st
-from wcs import fields, publisher, sql
+from wcs import fields, sql
 from wcs.formdata import Evolution
 from wcs.formdef import FormDef
 from wcs.qommon import force_str
diff --git a/tests/test_templates.py b/tests/test_templates.py
index 908d60db..ee20667d 100644
--- a/tests/test_templates.py
+++ b/tests/test_templates.py
@@ -5,15 +5,14 @@ import os
 import string
 
 import pytest
+from django.test import override_settings
+from django.utils.timezone import now
 
 try:
-    import langdetect
+    import langdetect  # pylint: disable=unused-import
 except ImportError:
     langdetect = None
 
-from django.test import override_settings
-from django.utils.timezone import now
-
 from wcs import fields
 from wcs.formdef import FormDef
 from wcs.qommon.http_request import HTTPRequest
diff --git a/tests/test_texts.py b/tests/test_texts.py
index cc37511f..a07ba358 100644
--- a/tests/test_texts.py
+++ b/tests/test_texts.py
@@ -1,5 +1,4 @@
 import shutil
-import sys
 
 from quixote import cleanup
 
diff --git a/tests/test_upload_storage.py b/tests/test_upload_storage.py
index 0850acb2..4d6a3742 100644
--- a/tests/test_upload_storage.py
+++ b/tests/test_upload_storage.py
@@ -8,7 +8,6 @@ import pytest
 from webtest import Upload
 
 from wcs import fields
-from wcs.categories import Category
 from wcs.formdef import FormDef
 from wcs.qommon.ident.password_accounts import PasswordAccount
 from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
diff --git a/tests/test_users.py b/tests/test_users.py
index 36345717..3518aa17 100644
--- a/tests/test_users.py
+++ b/tests/test_users.py
@@ -1,14 +1,9 @@
-import datetime
-import os
-import random
 import shutil
-import sys
-import time
 
 import pytest
 from quixote import cleanup
 
-from wcs import fields, publisher
+from wcs import fields
 from wcs.variables import LazyUser
 
 from .utilities import create_temporary_pub
diff --git a/tests/test_workflows.py b/tests/test_workflows.py
index c80a0675..640d56ea 100644
--- a/tests/test_workflows.py
+++ b/tests/test_workflows.py
@@ -59,7 +59,6 @@ from wcs.wf.criticality import MODE_DEC, MODE_INC, MODE_SET, ModifyCriticalityWo
 from wcs.wf.dispatch import DispatchWorkflowStatusItem
 from wcs.wf.edit_carddata import EditCarddataWorkflowStatusItem
 from wcs.wf.export_to_model import ExportToModel, transform_to_pdf
-from wcs.wf.external_workflow import ExternalWorkflowGlobalAction
 from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
 from wcs.wf.geolocate import GeolocateWorkflowStatusItem
 from wcs.wf.jump import JumpWorkflowStatusItem, _apply_timeouts
-- 
2.30.2

