Skip to content

Commit

Permalink
pylint: Fix cyclic-import
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Stanislav Levin <[email protected]>
  • Loading branch information
stanislavlevin authored and flo-renaud committed Jan 10, 2023
1 parent ccdc94b commit 4352bd5
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ipalib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ def packages(self):
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),
Expand Down
2 changes: 1 addition & 1 deletion ipalib/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def __signature__(cls, obj):
# 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
Expand Down
2 changes: 1 addition & 1 deletion ipaplatform/osinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def platform(self):
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:
Expand Down
3 changes: 2 additions & 1 deletion ipaserver/install/installutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions ipatests/pytest_ipa/integration/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def to_dict(self):

@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):
Expand Down Expand Up @@ -156,7 +156,7 @@ def static_roles(self):
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
Expand Down
2 changes: 1 addition & 1 deletion ipatests/pytest_ipa/integration/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion ipatests/pytest_ipa/integration/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import time

from ipaplatform.paths import paths
from . import tasks


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -175,6 +174,7 @@ def _restart_resolved(self):
# 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)
Expand Down Expand Up @@ -293,6 +293,7 @@ def _restart_network_manager(self):
# 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)
Expand Down

0 comments on commit 4352bd5

Please sign in to comment.