Skip to content

Commit

Permalink
Fixed new pylint reports
Browse files Browse the repository at this point in the history
Prepares for bumping pylint by fixing some errors reportes by
newer version.
  • Loading branch information
ssbarnea committed Jul 17, 2021
1 parent 142a52c commit 0e83d05
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 52 deletions.
6 changes: 3 additions & 3 deletions src/molecule/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def __getitem__(self, i):
def get(self, key, default):
return self.__dict__.get(key, default)

def append(self, element) -> None:
self.__dict__[str(element)] = element
super(UserListMap, self).append(element)
def append(self, item) -> None:
self.__dict__[str(item)] = item
super(UserListMap, self).append(item)


@lru_cache()
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ def _combine(self, env=os.environ, keep_string=None) -> MutableMapping:
environment variables.
1. Loads Molecule defaults.
2. Loads a base config (if provided) and merges ontop of defaults.
3. Loads the scenario's ``molecule file`` and merges ontop of previous
2. Loads a base config (if provided) and merges on top of defaults.
3. Loads the scenario's ``molecule file`` and merges on top of previous
merge.
:return: dict
Expand Down
6 changes: 4 additions & 2 deletions src/molecule/dependency/ansible_galaxy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ def __init__(self, config):

self.command = "ansible-galaxy"

@abc.abstractproperty
@property
@abc.abstractmethod
def install_path(self): # noqa cover
pass

@abc.abstractproperty
@property
@abc.abstractmethod
def requirements_file(self): # noqa cover
pass

Expand Down
3 changes: 2 additions & 1 deletion src/molecule/dependency/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def execute(self): # pragma: no cover
:return: None
"""

@abc.abstractproperty
@property
@abc.abstractmethod
def default_options(self): # pragma: no cover
"""
Get default CLI arguments provided to ``cmd`` as a dict.
Expand Down
36 changes: 15 additions & 21 deletions src/molecule/driver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
# DEALINGS IN THE SOFTWARE.
"""Base Driver Module."""

import abc
import inspect
import os
from abc import ABCMeta, abstractmethod

import pkg_resources

Expand All @@ -32,7 +32,7 @@
class Driver(object):
"""Driver Class."""

__metaclass__ = abc.ABCMeta
__metaclass__ = ABCMeta

def __init__(self, config=None):
"""
Expand All @@ -43,27 +43,18 @@ def __init__(self, config=None):
"""
self._config = config
self._path = os.path.abspath(os.path.dirname(inspect.getfile(self.__class__)))
self.module = self.__module__.split(".")[0]
self.module = self.__module__.split(".", maxsplit=1)[0]
self.version = pkg_resources.get_distribution(self.module).version

@property # type: ignore
@abc.abstractmethod
def name(self): # pragma: no cover
@property
@abstractmethod
def name(self) -> str: # pragma: no cover
"""
Name of the driver and returns a string.
:returns: str
"""

@name.setter # type: ignore
@abc.abstractmethod
def name(self, value): # pragma: no cover
"""
Driver name setter and returns None.
:returns: None
"""

@property
def testinfra_options(self):
"""
Expand All @@ -76,7 +67,8 @@ def testinfra_options(self):
"ansible-inventory": self._config.provisioner.inventory_directory,
}

@abc.abstractproperty
@property
@abstractmethod
def login_cmd_template(self): # pragma: no cover
"""
Get the login command template to be populated by ``login_options`` as \
Expand All @@ -85,23 +77,25 @@ def login_cmd_template(self): # pragma: no cover
:returns: str
"""

@abc.abstractproperty
@property
@abstractmethod
def default_ssh_connection_options(self): # pragma: no cover
"""
SSH client options and returns a list.
:returns: list
"""

@abc.abstractproperty
@property
@abstractmethod
def default_safe_files(self): # pragma: no cover
"""
Generate files to be preserved.
:returns: list
"""

@abc.abstractmethod
@abstractmethod
def login_options(self, instance_name): # pragma: no cover
"""
Options used in the login command and returns a dict.
Expand All @@ -110,7 +104,7 @@ def login_options(self, instance_name): # pragma: no cover
:returns: dict
"""

@abc.abstractmethod
@abstractmethod
def ansible_connection_options(self, instance_name): # pragma: no cover
"""
Ansible specific connection options supplied to inventory and returns a \
Expand All @@ -120,7 +114,7 @@ def ansible_connection_options(self, instance_name): # pragma: no cover
:returns: dict
"""

@abc.abstractmethod
@abstractmethod
def sanity_checks(self):
"""
Confirm that driver is usable.
Expand Down
6 changes: 4 additions & 2 deletions src/molecule/lint/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ def __init__(self, config):
"""
self._config = config

@abc.abstractproperty
@property
@abc.abstractmethod
def default_options(self): # pragma: no cover
"""
Provide Default CLI arguments to ``cmd`` and returns a dict.
:return: dict
"""

@abc.abstractproperty
@property
@abc.abstractmethod
def default_env(self): # pragma: no cover
"""
Provide default env variables to ``cmd`` and returns a dict.
Expand Down
6 changes: 4 additions & 2 deletions src/molecule/provisioner/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ def __init__(self, config):
"""
self._config = config

@abc.abstractproperty
@property
@abc.abstractmethod
def default_options(self): # pragma: no cover
"""
Get default CLI arguments provided to ``cmd`` as a dict.
:return: dict
"""

@abc.abstractproperty
@property
@abc.abstractmethod
def default_env(self): # pragma: no cover
"""
Get default env variables provided to ``cmd`` as a dict.
Expand Down
32 changes: 16 additions & 16 deletions src/molecule/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,22 @@ def ephemeral_directory(self):
path = ephemeral_directory(project_scenario_directory)

if os.environ.get("MOLECULE_PARALLEL", False) and not self._lock:
self._lock = open(os.path.join(path, ".lock"), "w")
for i in range(1, 5):
try:
fcntl.lockf(self._lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
break
except OSError:
delay = 30 * i
LOG.warning(
"Retrying to acquire lock on %s, waiting for %s seconds",
path,
delay,
)
sleep(delay)
else:
LOG.warning("Timedout trying to acquire lock on %s", path)
raise SystemExit(RC_TIMEOUT)
with open(os.path.join(path, ".lock"), "w") as self._lock:
for i in range(1, 5):
try:
fcntl.lockf(self._lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
break
except OSError:
delay = 30 * i
LOG.warning(
"Retrying to acquire lock on %s, waiting for %s seconds",
path,
delay,
)
sleep(delay)
else:
LOG.warning("Timedout trying to acquire lock on %s", path)
raise SystemExit(RC_TIMEOUT)

return path

Expand Down
9 changes: 6 additions & 3 deletions src/molecule/verifier/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,26 @@ def __init__(self, config=None):
"""
self._config = config

@abc.abstractproperty
@property
@abc.abstractmethod
def name(self): # pragma: no cover
"""
Name of the verifier and returns a string.
:returns: str
"""

@abc.abstractproperty
@property
@abc.abstractmethod
def default_options(self): # pragma: no cover
"""
Get default CLI arguments provided to ``cmd`` as a dict.
:return: dict
"""

@abc.abstractproperty
@property
@abc.abstractmethod
def default_env(self): # pragma: no cover
"""
Get default env variables provided to ``cmd`` as a dict.
Expand Down

0 comments on commit 0e83d05

Please sign in to comment.