[elbe-devel] [PATCH 4/4] flake8: mark elbepack package as local one

Thomas Weißschuh thomas.weissschuh at linutronix.de
Wed Mar 27 17:23:07 CET 2024


Previously flake8 did not recognize that "elbepack" is the local
application package.
Therefore these imports were sorted in between other thirdparty
libraries.
Adapt the flake8 config and reorder all existing imports.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 conftest.py                       |  4 ++--
 elbepack/commands/buildchroot.py  |  4 ++--
 elbepack/commands/check-build.py  |  4 ++--
 elbepack/commands/control.py      |  4 ++--
 elbepack/commands/prjrepo.py      |  4 ++--
 elbepack/commands/updated.py      |  6 +++---
 elbepack/daemons/soap/__init__.py |  4 ++--
 elbepack/daemons/soap/esoap.py    | 10 +++++-----
 elbepack/daemons/soap/faults.py   |  4 ++--
 elbepack/db.py                    |  8 ++++----
 elbepack/debinstaller.py          |  6 +++---
 elbepack/egpg.py                  |  6 +++---
 elbepack/finetuning.py            |  6 +++---
 elbepack/hdimg.py                 |  4 ++--
 elbepack/soapclient.py            |  6 +++---
 elbepack/templates.py             |  6 +++---
 elbepack/tests/test_validate.py   |  4 ++--
 elbepack/tests/test_xml.py        |  4 ++--
 elbepack/updated.py               | 18 +++++++++---------
 elbepack/updated_monitors.py      |  4 ++--
 elbepack/validate.py              |  4 ++--
 elbepack/xmlpreprocess.py         | 10 +++++-----
 setup.cfg                         |  1 +
 setup.py                          |  4 ++--
 24 files changed, 68 insertions(+), 67 deletions(-)

diff --git a/conftest.py b/conftest.py
index 6ae9b3d480f7..523c3f243bb9 100644
--- a/conftest.py
+++ b/conftest.py
@@ -1,9 +1,9 @@
 import os
 
-import elbepack.directories
-
 import pytest
 
+import elbepack.directories
+
 
 def pytest_sessionstart(session):
     elbepack.directories.elbe_exe = os.path.join(os.path.dirname(__file__), 'elbe')
diff --git a/elbepack/commands/buildchroot.py b/elbepack/commands/buildchroot.py
index 45d0316294c4..6fe328ca634c 100644
--- a/elbepack/commands/buildchroot.py
+++ b/elbepack/commands/buildchroot.py
@@ -8,14 +8,14 @@ import subprocess
 import sys
 from optparse import OptionParser
 
+from sqlalchemy.exc import OperationalError
+
 from elbepack.cdroms import CDROM_SIZE
 from elbepack.db import ElbeDB
 from elbepack.elbeproject import ElbeProject
 from elbepack.elbexml import ValidationError
 from elbepack.log import elbe_logging
 
-from sqlalchemy.exc import OperationalError
-
 
 def run_command(argv):
     oparser = OptionParser(
diff --git a/elbepack/commands/check-build.py b/elbepack/commands/check-build.py
index 2f417f004ffd..9a685152d9c0 100644
--- a/elbepack/commands/check-build.py
+++ b/elbepack/commands/check-build.py
@@ -12,6 +12,8 @@ import sys
 import tempfile
 import traceback
 
+import pexpect
+
 from elbepack import qemu_firmware
 from elbepack.directories import elbe_exe
 from elbepack.filesystem import TmpdirFilesystem
@@ -19,8 +21,6 @@ from elbepack.log import elbe_logging
 from elbepack.shellhelper import do, get_command_out
 from elbepack.treeutils import etree
 
-import pexpect
-
 
 def run_command(argv):
 
diff --git a/elbepack/commands/control.py b/elbepack/commands/control.py
index 64aad69b3014..0ce26fdc7107 100644
--- a/elbepack/commands/control.py
+++ b/elbepack/commands/control.py
@@ -8,13 +8,13 @@ from http.client import BadStatusLine
 from optparse import OptionGroup, OptionParser
 from urllib.error import URLError
 
+from suds import WebFault
+
 from elbepack.config import cfg
 from elbepack.elbexml import ValidationMode
 from elbepack.soapclient import ClientAction, ElbeSoapClient
 from elbepack.version import elbe_version
 
-from suds import WebFault
-
 
 def run_command(argv):
 
diff --git a/elbepack/commands/prjrepo.py b/elbepack/commands/prjrepo.py
index 58d23867ac32..220d956bba7a 100644
--- a/elbepack/commands/prjrepo.py
+++ b/elbepack/commands/prjrepo.py
@@ -8,12 +8,12 @@ from http.client import BadStatusLine
 from optparse import OptionGroup, OptionParser
 from urllib.error import URLError
 
+from suds import WebFault
+
 from elbepack.config import cfg
 from elbepack.soapclient import ElbeSoapClient, RepoAction
 from elbepack.version import elbe_version
 
-from suds import WebFault
-
 
 def run_command(argv):
 
diff --git a/elbepack/commands/updated.py b/elbepack/commands/updated.py
index d8da2313e3e7..dacd41b898a3 100644
--- a/elbepack/commands/updated.py
+++ b/elbepack/commands/updated.py
@@ -9,12 +9,12 @@ import sys
 from optparse import OptionParser
 from wsgiref.simple_server import make_server
 
-from elbepack.updated import UpdateApplication, UpdateService, UpdateStatus
-from elbepack.updated_monitors import FileMonitor
-
 from spyne.protocol.soap import Soap11
 from spyne.server.wsgi import WsgiApplication
 
+from elbepack.updated import UpdateApplication, UpdateService, UpdateStatus
+from elbepack.updated_monitors import FileMonitor
+
 try:
     from elbepack.updated_monitors import USBMonitor
     usbmonitor_available = True
diff --git a/elbepack/daemons/soap/__init__.py b/elbepack/daemons/soap/__init__.py
index 2ce2bee85efa..0d28c509ef19 100644
--- a/elbepack/daemons/soap/__init__.py
+++ b/elbepack/daemons/soap/__init__.py
@@ -8,12 +8,12 @@ from beaker.middleware import SessionMiddleware
 
 from cherrypy.process.plugins import SimplePlugin
 
-from elbepack.projectmanager import ProjectManager
-
 from spyne import Application
 from spyne.protocol.soap import Soap11
 from spyne.server.wsgi import WsgiApplication
 
+from elbepack.projectmanager import ProjectManager
+
 from .esoap import ESoap
 
 logging.getLogger('spyne').setLevel(logging.INFO)
diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
index da3f51af06a6..f0e30f9391cf 100644
--- a/elbepack/daemons/soap/esoap.py
+++ b/elbepack/daemons/soap/esoap.py
@@ -10,16 +10,16 @@ import subprocess
 import tarfile
 from tempfile import NamedTemporaryFile
 
-from elbepack.elbexml import ValidationMode
-from elbepack.filesystem import hostfs
-from elbepack.shellhelper import system
-from elbepack.version import elbe_version, is_devel
-
 from spyne.decorator import rpc
 from spyne.model.complex import Array
 from spyne.model.primitive import Boolean, Integer, String
 from spyne.service import ServiceBase
 
+from elbepack.elbexml import ValidationMode
+from elbepack.filesystem import hostfs
+from elbepack.shellhelper import system
+from elbepack.version import elbe_version, is_devel
+
 from .authentication import authenticated_admin, authenticated_uid
 from .datatypes import SoapCmdReply, SoapFile, SoapProject
 from .faults import soap_faults
diff --git a/elbepack/daemons/soap/faults.py b/elbepack/daemons/soap/faults.py
index 6552162bfe32..c9d870ff88ad 100644
--- a/elbepack/daemons/soap/faults.py
+++ b/elbepack/daemons/soap/faults.py
@@ -5,12 +5,12 @@
 from functools import wraps
 from traceback import format_exc
 
+from spyne.model.fault import Fault
+
 from elbepack.db import ElbeDBError, InvalidLogin
 from elbepack.elbexml import ValidationError
 from elbepack.projectmanager import InvalidState, ProjectManagerError
 
-from spyne.model.fault import Fault
-
 
 class SoapElbeDBError(Fault):
     def __init__(self, dberr):
diff --git a/elbepack/db.py b/elbepack/db.py
index a93bddead2fa..3de4b628afcf 100644
--- a/elbepack/db.py
+++ b/elbepack/db.py
@@ -13,10 +13,6 @@ from shutil import copyfile, copyfileobj, rmtree
 from threading import Thread
 from urllib.parse import quote
 
-from elbepack.dosunix import dos2unix
-from elbepack.elbeproject import ElbeProject
-from elbepack.elbexml import ElbeXML, ValidationMode
-
 from passlib.hash import pbkdf2_sha512
 
 from sqlalchemy import (
@@ -33,6 +29,10 @@ from sqlalchemy.exc import OperationalError
 from sqlalchemy.orm import declarative_base, relationship, scoped_session, sessionmaker
 from sqlalchemy.orm.exc import NoResultFound
 
+from elbepack.dosunix import dos2unix
+from elbepack.elbeproject import ElbeProject
+from elbepack.elbexml import ElbeXML, ValidationMode
+
 
 Base = declarative_base()
 
diff --git a/elbepack/debinstaller.py b/elbepack/debinstaller.py
index 4e7493421e3e..948ad5aeb4c7 100644
--- a/elbepack/debinstaller.py
+++ b/elbepack/debinstaller.py
@@ -9,14 +9,14 @@ import sys
 from shutil import copyfile
 from urllib.request import urlopen
 
+from gpg import core
+from gpg.constants import PROTOCOL_OpenPGP
+
 from elbepack.egpg import OverallStatus, check_signature
 from elbepack.filesystem import TmpdirFilesystem
 from elbepack.hashes import HashValidationFailed, HashValidator
 from elbepack.shellhelper import system
 
-from gpg import core
-from gpg.constants import PROTOCOL_OpenPGP
-
 
 class InvalidSignature(Exception):
     pass
diff --git a/elbepack/egpg.py b/elbepack/egpg.py
index 1a8a01f06c34..aff1e82b24a4 100644
--- a/elbepack/egpg.py
+++ b/elbepack/egpg.py
@@ -6,13 +6,13 @@ import logging
 import os
 import subprocess
 
-from elbepack.filesystem import hostfs
-from elbepack.shellhelper import get_command_out, system
-
 from gpg import core
 from gpg.constants import PROTOCOL_OpenPGP, sig, sigsum
 from gpg.errors import GPGMEError, InvalidSigners, KeyNotFound
 
+from elbepack.filesystem import hostfs
+from elbepack.shellhelper import get_command_out, system
+
 
 elbe_internal_key_param = """
 <GnupgKeyParms format="internal">
diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index ddb67a37c681..b1dd912f6810 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -11,6 +11,9 @@ from shutil import rmtree
 
 from apt.package import FetchError
 
+from gpg import core
+from gpg.constants import PROTOCOL_OpenPGP
+
 from elbepack.egpg import unlock_key
 from elbepack.filesystem import ImgMountFilesystem
 from elbepack.packers import default_packer, packers
@@ -18,9 +21,6 @@ from elbepack.repomanager import UpdateRepo
 from elbepack.rpcaptcache import get_rpcaptcache
 from elbepack.shellhelper import chroot, do, get_command_out
 
-from gpg import core
-from gpg.constants import PROTOCOL_OpenPGP
-
 
 class FinetuningException(Exception):
     pass
diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index 1f1e93577d69..0d4da26b2686 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -7,12 +7,12 @@ import os
 import subprocess
 from pathlib import Path
 
+import parted
+
 from elbepack.filesystem import Filesystem, size_to_int
 from elbepack.fstab import fstabentry, hdpart, mountpoint_dict
 from elbepack.shellhelper import chroot, do, get_command_out
 
-import parted
-
 
 def mkfs_mtd(mtd, fslabel, target):
 
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index 90091ab55617..25d1caf19f08 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -16,14 +16,14 @@ from urllib.error import URLError
 
 import deb822
 
+from suds import WebFault
+from suds.client import Client
+
 from elbepack.config import cfg
 from elbepack.elbexml import ElbeXML, ValidationMode
 from elbepack.filesystem import Filesystem
 from elbepack.version import elbe_initvm_packagelist, elbe_version
 
-from suds import WebFault
-from suds.client import Client
-
 
 def set_suds_debug(debug):
     if debug:
diff --git a/elbepack/templates.py b/elbepack/templates.py
index 98f2fcacca5c..1cb44ed1cf79 100644
--- a/elbepack/templates.py
+++ b/elbepack/templates.py
@@ -5,13 +5,13 @@
 import importlib.resources
 import os
 
+from mako import exceptions
+from mako.template import Template
+
 import elbepack
 import elbepack.makofiles
 from elbepack.treeutils import etree
 
-from mako import exceptions
-from mako.template import Template
-
 
 def fix_linebreak_escapes(s):
     return s.replace('\\\n', '${"\\\\"}\n')
diff --git a/elbepack/tests/test_validate.py b/elbepack/tests/test_validate.py
index c6580a903f20..5c0885c3e294 100644
--- a/elbepack/tests/test_validate.py
+++ b/elbepack/tests/test_validate.py
@@ -5,10 +5,10 @@
 import itertools
 import os
 
-from elbepack.directories import run_elbe
-
 import pytest
 
+from elbepack.directories import run_elbe
+
 
 def _test_cases():
     return [
diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
index 16c80206d4d1..b35c4e6a9481 100644
--- a/elbepack/tests/test_xml.py
+++ b/elbepack/tests/test_xml.py
@@ -4,11 +4,11 @@
 
 import subprocess
 
+import pytest
+
 from elbepack.directories import run_elbe
 from elbepack.tests import parametrize_xml_test_files, xml_test_files
 
-import pytest
-
 
 def _delete_project(uuid):
     run_elbe(['control', 'del_project', uuid])
diff --git a/elbepack/updated.py b/elbepack/updated.py
index 203b5831ca83..4c94a765e203 100644
--- a/elbepack/updated.py
+++ b/elbepack/updated.py
@@ -17,6 +17,15 @@ import apt
 
 import apt_pkg
 
+from packaging import version
+
+from spyne import Application
+from spyne.decorator import rpc
+from spyne.model.primitive import String
+from spyne.service import ServiceBase
+
+from suds.client import Client
+
 from elbepack.aptprogress import (
     ElbeAcquireProgress,
     ElbeInstallProgress,
@@ -27,15 +36,6 @@ from elbepack.egpg import unsign_file
 from elbepack.shellhelper import system
 from elbepack.treeutils import etree
 
-from packaging import version
-
-from spyne import Application
-from spyne.decorator import rpc
-from spyne.model.primitive import String
-from spyne.service import ServiceBase
-
-from suds.client import Client
-
 
 class UpdateStatus:
 
diff --git a/elbepack/updated_monitors.py b/elbepack/updated_monitors.py
index 81305f4fec8e..5f6a7e95037c 100644
--- a/elbepack/updated_monitors.py
+++ b/elbepack/updated_monitors.py
@@ -6,12 +6,12 @@
 import os
 import threading
 
-from elbepack.updated import handle_update_file, is_update_file
-
 import pyinotify
 
 import pyudev
 
+from elbepack.updated import handle_update_file, is_update_file
+
 
 class UpdateMonitor:
     def __init__(self, status):
diff --git a/elbepack/validate.py b/elbepack/validate.py
index 49683ff74e00..1fd57c80d2e3 100644
--- a/elbepack/validate.py
+++ b/elbepack/validate.py
@@ -5,11 +5,11 @@
 import os
 import sys
 
-from elbepack.schema import xml_schema_file
-
 from lxml import etree
 from lxml.etree import XMLParser, parse
 
+from elbepack.schema import xml_schema_file
+
 
 def error_log_to_strings(error_log):
     errors = []
diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
index 46bd8f157ee5..6422a9d851a8 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -14,6 +14,11 @@ from optparse import OptionGroup
 from urllib.error import HTTPError, URLError
 from urllib.request import urlopen
 
+from lxml import etree
+from lxml.etree import Element, SubElement, XMLParser
+
+from passlib.hash import sha512_crypt
+
 from elbepack.archivedir import ArchivedirError, combinearchivedir
 from elbepack.config import cfg
 from elbepack.directories import run_elbe
@@ -21,11 +26,6 @@ from elbepack.isooptions import iso_option_valid
 from elbepack.schema import xml_schema_file
 from elbepack.validate import error_log_to_strings
 
-from lxml import etree
-from lxml.etree import Element, SubElement, XMLParser
-
-from passlib.hash import sha512_crypt
-
 
 # list of sections that are allowed to exists multiple times before
 # preprocess and that childrens are merge into one section during preprocess
diff --git a/setup.cfg b/setup.cfg
index a1f8bc10065a..282351e1f25b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -5,3 +5,4 @@ extend-exclude =
 	elbe-project-*,
 	debian/,
 	initvm/
+application-import-names = elbepack
diff --git a/setup.py b/setup.py
index 25c43d4e5e19..458bbc7a5443 100644
--- a/setup.py
+++ b/setup.py
@@ -7,11 +7,11 @@
 import os
 import subprocess
 
-from elbepack.version import elbe_version
-
 from setuptools import setup
 from setuptools.command.install import install
 
+from elbepack.version import elbe_version
+
 
 def abspath(path):
     """ method to determine absolute path

-- 
2.44.0



More information about the elbe-devel mailing list