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

View File

@ -949,7 +949,7 @@ class API(plugable.API):
ipaserver.plugins,
)
else:
import ipaclient.remote_plugins
import ipaclient.remote_plugins # pylint: disable=cyclic-import
import ipaclient.plugins
result = (
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
# an instance
if obj is None:
from ipalib import api
from ipalib import api # pylint: disable=cyclic-import
obj = cls(api=api)
cls._signature = signature = create_signature(obj)
return signature

View File

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

View File

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

View File

@ -100,11 +100,11 @@ class Config(pytest_multihost.config.Config):
@classmethod
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)
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)
def filter(self, descriptions):
@ -156,7 +156,7 @@ class Domain(pytest_multihost.config.Domain):
raise LookupError(self.type)
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:
return Host

View File

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

View File

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