pylint: Fix cyclic-import

Most of `cyclic-import` issues reported by Pylint are false-positive
and they are already handled in the code, but several ones are the
actual errors.

Fixes: https://pagure.io/freeipa/issue/9232
Fixes: https://pagure.io/freeipa/issue/9278
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Stanislav Levin <slev@altlinux.org>
This commit is contained in:
Stanislav Levin 2022-12-02 17:29:45 +03:00 committed by Florence Blanc-Renaud
parent ccdc94b0e1
commit 4352bd5a50
7 changed files with 11 additions and 9 deletions
ipalib
ipaplatform
ipaserver/install
ipatests/pytest_ipa/integration

View File

@ -949,7 +949,7 @@ class API(plugable.API):
ipaserver.plugins, ipaserver.plugins,
) )
else: else:
import ipaclient.remote_plugins import ipaclient.remote_plugins # pylint: disable=cyclic-import
import ipaclient.plugins import ipaclient.plugins
result = ( result = (
ipaclient.remote_plugins.get_package(self), ipaclient.remote_plugins.get_package(self),

View File

@ -449,7 +449,7 @@ class Command(HasParam):
# special, rare case: user calls help() on a plugin class instead of # special, rare case: user calls help() on a plugin class instead of
# an instance # an instance
if obj is None: if obj is None:
from ipalib import api from ipalib import api # pylint: disable=cyclic-import
obj = cls(api=api) obj = cls(api=api)
cls._signature = signature = create_signature(obj) cls._signature = signature = create_signature(obj)
return signature return signature

View File

@ -218,7 +218,7 @@ class OSInfo(Mapping):
def container(self): def container(self):
if self._container is not None: if self._container is not None:
return self._container return self._container
from ipaplatform.tasks import tasks from ipaplatform.tasks import tasks # pylint: disable=cyclic-import
try: try:
self._container = tasks.detect_container() self._container = tasks.detect_container()
except NotImplementedError: except NotImplementedError:

View File

@ -56,7 +56,7 @@ from ipalib import api, errors, x509
from ipalib.install import dnsforwarders from ipalib.install import dnsforwarders
from ipapython.dn import DN from ipapython.dn import DN
from ipapython.dnsutil import DNSName, resolve from ipapython.dnsutil import DNSName, resolve
from ipaserver.install import certs, service, sysupgrade from ipaserver.install import certs, sysupgrade
from ipaplatform import services from ipaplatform import services
from ipaplatform.paths import paths from ipaplatform.paths import paths
from ipaplatform.tasks import tasks from ipaplatform.tasks import tasks
@ -1012,6 +1012,7 @@ def check_entropy():
""" """
Checks if the system has enough entropy, if not, displays warning message Checks if the system has enough entropy, if not, displays warning message
""" """
from . import service # pylint: disable=cyclic-import
try: try:
with open(paths.ENTROPY_AVAIL, 'r') as efname: with open(paths.ENTROPY_AVAIL, 'r') as efname:
if int(efname.read()) < 200: if int(efname.read()) < 200:

View File

@ -100,11 +100,11 @@ class Config(pytest_multihost.config.Config):
@classmethod @classmethod
def from_env(cls, env): def from_env(cls, env):
from ipatests.pytest_ipa.integration.env_config import config_from_env from .env_config import config_from_env # pylint: disable=cyclic-import
return config_from_env(env) return config_from_env(env)
def to_env(self, **kwargs): def to_env(self, **kwargs):
from ipatests.pytest_ipa.integration.env_config import config_to_env from .env_config import config_to_env # pylint: disable=cyclic-import
return config_to_env(self, **kwargs) return config_to_env(self, **kwargs)
def filter(self, descriptions): def filter(self, descriptions):
@ -156,7 +156,7 @@ class Domain(pytest_multihost.config.Domain):
raise LookupError(self.type) raise LookupError(self.type)
def get_host_class(self, host_dict): def get_host_class(self, host_dict):
from ipatests.pytest_ipa.integration.host import Host, WinHost from .host import Host, WinHost # pylint: disable=cyclic-import
if self.is_ipa_type: if self.is_ipa_type:
return Host return Host

View File

@ -231,7 +231,7 @@ class Firewall(FirewallBase):
def __init__(self, host): def __init__(self, host):
"""Initialize with host where firewall changes should be applied""" """Initialize with host where firewall changes should be applied"""
# break circular dependency # break circular dependency
from .tasks import get_platform from .tasks import get_platform # pylint: disable=cyclic-import
self.host = host self.host = host
platform = get_platform(host) platform = get_platform(host)

View File

@ -6,7 +6,6 @@ import textwrap
import time import time
from ipaplatform.paths import paths from ipaplatform.paths import paths
from . import tasks
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -175,6 +174,7 @@ class ResolvedResolver(Resolver):
# scenarios) can exceed the threshold configured in systemd option # scenarios) can exceed the threshold configured in systemd option
# StartLimitIntervalSec. In that case restart fails, but we can simply # StartLimitIntervalSec. In that case restart fails, but we can simply
# continue trying until it succeeds # continue trying until it succeeds
from . import tasks # pylint: disable=cyclic-import
tasks.run_repeatedly( tasks.run_repeatedly(
self.host, ['systemctl', 'restart', 'systemd-resolved.service'], self.host, ['systemctl', 'restart', 'systemd-resolved.service'],
timeout=15) timeout=15)
@ -293,6 +293,7 @@ class NetworkManagerResolver(Resolver):
# scenarios) can exceed the threshold configured in systemd option # scenarios) can exceed the threshold configured in systemd option
# StartLimitIntervalSec. In that case restart fails, but we can simply # StartLimitIntervalSec. In that case restart fails, but we can simply
# continue trying until it succeeds # continue trying until it succeeds
from . import tasks # pylint: disable=cyclic-import
tasks.run_repeatedly( tasks.run_repeatedly(
self.host, ['systemctl', 'restart', 'NetworkManager.service'], self.host, ['systemctl', 'restart', 'NetworkManager.service'],
timeout=15) timeout=15)