Skip to content

Commit

Permalink
Merge pull request rhinstaller#6058 from KKoukiou/enable-isort
Browse files Browse the repository at this point in the history
ruff: enable isort rules and autofix all isort warnings
  • Loading branch information
KKoukiou authored Dec 19, 2024
2 parents e9009aa + 4166b0a commit 9c618ac
Show file tree
Hide file tree
Showing 579 changed files with 4,897 additions and 2,699 deletions.
48 changes: 29 additions & 19 deletions anaconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
# ...still messy (2013-07-12)
# A lot less messy now. :) (2016-10-13)

import os
import atexit
import os
import signal
import sys
import time
import signal

import pid

from pyanaconda.modules.common.structures.rescue import RescueData
Expand Down Expand Up @@ -198,23 +199,22 @@ def setup_environment():
from pyanaconda.core.constants import ADDON_PATHS
sys.path.extend(ADDON_PATHS)

from pyanaconda import startup_utils
from pyanaconda.core import constants, path, util
from pyanaconda.core.i18n import _
from pyanaconda.core.kernel import kernel_arguments
# init threading before Gtk can do anything and before we start using threads
from pyanaconda.core.threads import thread_manager
from pyanaconda.core.i18n import _
from pyanaconda.core import util, constants, path
from pyanaconda import startup_utils

# do this early so we can set flags before initializing logging
from pyanaconda.flags import flags
from pyanaconda.core.kernel import kernel_arguments
opts = parse_arguments(boot_cmdline=kernel_arguments)

from pyanaconda.core.configuration.anaconda import conf
conf.set_from_opts(opts)

# Set up logging as early as possible.
from pyanaconda import anaconda_logging
from pyanaconda import anaconda_loggers
from pyanaconda import anaconda_loggers, anaconda_logging
anaconda_logging.init(write_to_journal=conf.target.is_hardware)
anaconda_logging.logger.setupVirtio(opts.virtiolog)

Expand Down Expand Up @@ -273,13 +273,15 @@ def setup_environment():
opts.display_mode = constants.DisplayModes.TUI
opts.noninteractive = True

from pyanaconda import gnome_remote_desktop
from pyanaconda import kickstart
# we are past the --version and --help shortcut so we can import display &
# startup_utils, which import Blivet, without slowing down anything critical
from pyanaconda import display
from pyanaconda import startup_utils
from pyanaconda import rescue
from pyanaconda import (
display,
gnome_remote_desktop,
kickstart,
rescue,
startup_utils,
)

# Print the usual "startup note" that contains Anaconda version
# and short usage & bug reporting instructions.
Expand Down Expand Up @@ -398,8 +400,8 @@ def _earlyExceptionHandler(ty, value, traceback):

# Pick up any changes from interactive-defaults.ks that would
# otherwise be covered by the dracut KS parser.
from pyanaconda.modules.common.constants.services import STORAGE, RUNTIME
from pyanaconda.modules.common.constants.objects import BOOTLOADER
from pyanaconda.modules.common.constants.services import RUNTIME, STORAGE

bootloader_proxy = STORAGE.get_proxy(BOOTLOADER)
runtime_proxy = RUNTIME.get_proxy()
Expand Down Expand Up @@ -445,7 +447,11 @@ def _earlyExceptionHandler(ty, value, traceback):
startup_utils.initialize_locale(opts, text_mode=anaconda.tui_mode)

# Initialize the network now, in case the display needs it
from pyanaconda.network import initialize_network, wait_for_connecting_NM_thread, wait_for_connected_NM
from pyanaconda.network import (
initialize_network,
wait_for_connected_NM,
wait_for_connecting_NM_thread,
)

initialize_network()
# If required by user, wait for connection before starting the installation.
Expand Down Expand Up @@ -476,8 +482,8 @@ def _earlyExceptionHandler(ty, value, traceback):
startup_utils.set_storage_checker_minimal_ram_size(anaconda.display_mode)

# Set the disk images.
from pyanaconda.modules.common.constants.objects import DISK_SELECTION
from pyanaconda.argument_parsing import name_path_pairs
from pyanaconda.modules.common.constants.objects import DISK_SELECTION
disk_select_proxy = STORAGE.get_proxy(DISK_SELECTION)
disk_images = {}

Expand Down Expand Up @@ -530,12 +536,15 @@ def _earlyExceptionHandler(ty, value, traceback):
# else currently talks to the Subscription DBus module,
# we only check if organization id & at least one activation
# key are available
from pyanaconda.modules.common.util import is_module_available
from pyanaconda.modules.common.constants.services import SUBSCRIPTION
from pyanaconda.modules.common.util import is_module_available

if is_module_available(SUBSCRIPTION):
from pyanaconda.ui.lib.subscription import org_keys_sufficient, \
register_and_subscribe, kickstart_error_handler
from pyanaconda.ui.lib.subscription import (
kickstart_error_handler,
org_keys_sufficient,
register_and_subscribe,
)
if org_keys_sufficient():
thread_manager.add_thread(
name=constants.THREAD_SUBSCRIPTION,
Expand All @@ -560,6 +569,7 @@ def _earlyExceptionHandler(ty, value, traceback):

# Create pre-install snapshots
from pykickstart.constants import SNAPSHOT_WHEN_PRE_INSTALL

from pyanaconda.kickstart import check_kickstart_error
from pyanaconda.modules.common.constants.objects import SNAPSHOT
from pyanaconda.modules.common.task import sync_run_task
Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os, shutil
import os
import shutil
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
Expand Down
5 changes: 2 additions & 3 deletions dracut/driver_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,18 @@
/run/install/dd_packages to the target system.
"""

import fnmatch
import logging
import sys
import os
import subprocess
import fnmatch
import sys

# Import readline so raw_input gets readline features, like history, and
# backspace working right. Do not import readline if not connected to a tty
# because it breaks sometimes.
if os.isatty(0):
import readline # pylint:disable=unused-import
import shutil

from contextlib import contextmanager
from logging.handlers import SysLogHandler

Expand Down
20 changes: 13 additions & 7 deletions pyanaconda/anaconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@

import os
import sys
from tempfile import mkstemp
import threading
from tempfile import mkstemp

from pyanaconda.core.constants import DisplayModes, PAYLOAD_TYPE_RPM_OSTREE, ADDON_PATHS, \
PAYLOAD_TYPE_LIVE_IMAGE
from pyanaconda.anaconda_loggers import get_stdout_logger
from pyanaconda.core import constants
from pyanaconda.core.startup.dbus_launcher import AnacondaDBusLauncher
from pyanaconda.core.constants import (
ADDON_PATHS,
PAYLOAD_TYPE_LIVE_IMAGE,
PAYLOAD_TYPE_RPM_OSTREE,
DisplayModes,
)
from pyanaconda.core.kernel import kernel_arguments
from pyanaconda.core.path import open_with_perm
from pyanaconda.core.startup.dbus_launcher import AnacondaDBusLauncher
from pyanaconda.modules.common.constants.services import PAYLOADS
from pyanaconda.ui.lib.addons import collect_addon_ui_paths

from pyanaconda.anaconda_loggers import get_stdout_logger
stdoutLog = get_stdout_logger()

from pyanaconda.anaconda_loggers import get_module_logger

log = get_module_logger(__name__)


Expand Down Expand Up @@ -163,11 +168,12 @@ def log_display_mode(self):
constants.DISPLAY_MODE_NAME[self.display_mode])

def dumpState(self):
from meh import ExceptionInfo
from meh.dump import ReverseExceptionDump
from inspect import stack as _stack
from traceback import format_stack

from meh import ExceptionInfo
from meh.dump import ReverseExceptionDump

# Skip the frames for dumpState and the signal handler.
stack = _stack()[2:]
stack.reverse()
Expand Down
1 change: 1 addition & 0 deletions pyanaconda/anaconda_loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# than the constants module.

import logging

from pyanaconda.core import constants


Expand Down
15 changes: 11 additions & 4 deletions pyanaconda/anaconda_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@
#

import logging
from logging.handlers import SysLogHandler, SocketHandler
from systemd import journal
import os
import sys
import warnings
from logging.handlers import SocketHandler, SysLogHandler

from systemd import journal

from pyanaconda.core import constants
from pyanaconda.core.glib import (
LogLevelFlags,
LogWriterOutput,
log_set_handler,
log_set_writer_func,
log_writer_format_fields,
)
from pyanaconda.core.path import set_mode
from pyanaconda.core.glib import log_set_handler, log_set_writer_func, log_writer_format_fields, \
LogLevelFlags, LogWriterOutput

ENTRY_FORMAT = "%(asctime)s,%(msecs)03d %(levelname)s %(name)s: %(message)s"
STDOUT_FORMAT = "%(asctime)s %(message)s"
Expand All @@ -45,6 +51,7 @@
ANACONDA_SYSLOG_IDENTIFIER = "anaconda"

from threading import Lock

program_log_lock = Lock()


Expand Down
19 changes: 13 additions & 6 deletions pyanaconda/argument_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@
DESCRIPTION = "Anaconda is the installation program used by Fedora, " \
"Red Hat Enterprise Linux and some other distributions."

import fcntl
import itertools
import os
import struct
import sys
import fcntl
import termios
import struct

from argparse import ArgumentParser, ArgumentError, HelpFormatter, Namespace, Action, SUPPRESS
from argparse import (
SUPPRESS,
Action,
ArgumentError,
ArgumentParser,
HelpFormatter,
Namespace,
)

from blivet.arch import is_s390

from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.core.constants import VIRTIO_PORT, X_TIMEOUT, DisplayModes
from pyanaconda.core.kernel import KernelArguments
from pyanaconda.core.constants import DisplayModes, X_TIMEOUT, VIRTIO_PORT

from pyanaconda.anaconda_loggers import get_module_logger
log = get_module_logger(__name__)

# Help text formatting constants
Expand Down Expand Up @@ -512,6 +518,7 @@ def __call__(self, parser, namespace, values, _option_string=None):
help=help_parser.help_text("virtiolog"))

from pykickstart.constants import SELINUX_DISABLED, SELINUX_ENFORCING

from pyanaconda.core.constants import SELINUX_DEFAULT
ap.add_argument("--noselinux", dest="selinux", action="store_const",
const=SELINUX_DISABLED, default=SELINUX_DEFAULT,
Expand Down
3 changes: 2 additions & 1 deletion pyanaconda/core/async_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#

from queue import Queue
from pyanaconda.core.threads import thread_manager

from pyanaconda.core.glib import idle_add
from pyanaconda.core.threads import thread_manager


def run_in_loop(callback, *args, **kwargs):
Expand Down
28 changes: 19 additions & 9 deletions pyanaconda/core/configuration/anaconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,33 @@
import os

from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.core.configuration.base import (
Configuration,
ConfigurationError,
Section,
)
from pyanaconda.core.configuration.bootloader import BootloaderSection, BootloaderType
from pyanaconda.core.configuration.license import LicenseSection
from pyanaconda.core.configuration.localization import LocalizationSection
from pyanaconda.core.configuration.network import NetworkSection
from pyanaconda.core.configuration.payload import PayloadSection
from pyanaconda.core.configuration.profile import ProfileLoader
from pyanaconda.core.configuration.security import SecuritySection
from pyanaconda.core.configuration.storage import StorageSection
from pyanaconda.core.configuration.storage_constraints import StorageConstraints
from pyanaconda.core.configuration.system import SystemType, SystemSection
from pyanaconda.core.configuration.target import TargetType, TargetSection
from pyanaconda.core.configuration.base import Section, Configuration, ConfigurationError
from pyanaconda.core.configuration.profile import ProfileLoader
from pyanaconda.core.configuration.ui import UserInterfaceSection
from pyanaconda.core.configuration.system import SystemSection, SystemType
from pyanaconda.core.configuration.target import TargetSection, TargetType
from pyanaconda.core.configuration.timezone import TimezoneSection
from pyanaconda.core.configuration.localization import LocalizationSection
from pyanaconda.core.constants import ANACONDA_CONFIG_TMP, ANACONDA_CONFIG_DIR, \
GEOLOC_PROVIDER_FEDORA_GEOIP, GEOLOC_PROVIDER_HOSTIP, GEOLOC_DEFAULT_PROVIDER, \
GEOLOC_URL_FEDORA_GEOIP, GEOLOC_URL_HOSTIP
from pyanaconda.core.configuration.ui import UserInterfaceSection
from pyanaconda.core.constants import (
ANACONDA_CONFIG_DIR,
ANACONDA_CONFIG_TMP,
GEOLOC_DEFAULT_PROVIDER,
GEOLOC_PROVIDER_FEDORA_GEOIP,
GEOLOC_PROVIDER_HOSTIP,
GEOLOC_URL_FEDORA_GEOIP,
GEOLOC_URL_HOSTIP,
)

log = get_module_logger(__name__)

Expand Down
1 change: 1 addition & 0 deletions pyanaconda/core/configuration/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Author(s): Vendula Poncova <[email protected]>
#
from enum import Enum

from pyanaconda.core.configuration.base import Section


Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/core/configuration/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Author(s): Vendula Poncova <[email protected]>
#
from pyanaconda.core.configuration.base import Section
from pyanaconda.core.constants import SOURCE_TYPE_CLOSEST_MIRROR, SOURCE_TYPE_CDN
from pyanaconda.core.constants import SOURCE_TYPE_CDN, SOURCE_TYPE_CLOSEST_MIRROR


class PayloadSection(Section):
Expand Down
8 changes: 6 additions & 2 deletions pyanaconda/core/configuration/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
import os

from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.core.configuration.base import create_parser, read_config, get_option, \
ConfigurationError
from pyanaconda.core.configuration.base import (
ConfigurationError,
create_parser,
get_option,
read_config,
)

log = get_module_logger(__name__)

Expand Down
9 changes: 6 additions & 3 deletions pyanaconda/core/configuration/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
from enum import Enum

from blivet.size import Size

from pykickstart.constants import AUTOPART_TYPE_PLAIN, AUTOPART_TYPE_BTRFS, AUTOPART_TYPE_LVM, \
AUTOPART_TYPE_LVM_THINP
from pykickstart.constants import (
AUTOPART_TYPE_BTRFS,
AUTOPART_TYPE_LVM,
AUTOPART_TYPE_LVM_THINP,
AUTOPART_TYPE_PLAIN,
)

from pyanaconda.core.configuration.base import Section
from pyanaconda.core.configuration.utils import split_name_and_attributes
Expand Down
Loading

0 comments on commit 9c618ac

Please sign in to comment.