Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade pylint #3194

Merged
merged 1 commit into from
Jul 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ repos:
- enrich>=1.2.5
- subprocess-tee>=0.2.0
- repo: https://github.com/PyCQA/pylint
rev: pylint-2.7.2
rev: v2.9.3
hooks:
- id: pylint
additional_dependencies:
Expand Down
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
28 changes: 15 additions & 13 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,20 +43,19 @@ 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.
Expand All @@ -76,7 +75,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 +85,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 +112,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 +122,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
2 changes: 1 addition & 1 deletion src/molecule/test/unit/provisioner/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def test_link_vars(_instance):
source_host_vars = os.path.join(scenario_dir, os.path.pardir, "host_vars")
target_host_vars = os.path.join(inventory_dir, "host_vars")

open(source_hosts, "w").close()
open(source_hosts, "w").close() # pylint: disable=consider-using-with
os.mkdir(source_group_vars)
os.mkdir(source_host_vars)

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