From af8cd4eeef1c15411e4801c04c8a289385ed595f Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Fri, 27 Aug 2021 12:23:26 +0100 Subject: [PATCH] Address some pylint violations --- .pylintrc | 44 +------------------------ src/molecule_podman/driver.py | 4 +-- src/molecule_podman/test/__init__.py | 4 --- src/molecule_podman/test/conftest.py | 3 +- src/molecule_podman/test/test_driver.py | 6 ++-- src/molecule_podman/test/test_func.py | 4 +-- 6 files changed, 8 insertions(+), 57 deletions(-) diff --git a/.pylintrc b/.pylintrc index ce74c83..e744726 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,53 +3,11 @@ disable = # Disabled on purpose wrong-import-order, # managed by isort + line-too-long, # managed by black # TODO(ssbarnea): remove temporary skips adding during initial adoption: - abstract-method, - arguments-differ, - bad-continuation, - broad-except, - consider-merging-isinstance, - consider-using-in, - dangerous-default-value, - duplicate-code, fixme, - implicit-str-concat, import-error, - import-outside-toplevel, - inconsistent-return-statements, - invalid-name, - line-too-long, - logging-format-interpolation, - logging-not-lazy, - misplaced-comparison-constant, - missing-function-docstring, - missing-module-docstring, - no-else-raise, - no-else-return, - no-member, - no-self-argument, - no-self-use, - no-value-for-parameter, - not-callable, - protected-access, - raise-missing-from, - redefined-builtin, - redefined-outer-name, - subprocess-run-check, - super-init-not-called, - super-with-arguments, - too-few-public-methods, - too-many-ancestors, - too-many-arguments, - too-many-public-methods, - unidiomatic-typecheck, - unnecessary-comprehension, - unnecessary-lambda, unused-argument, - unused-import, - unused-variable, - useless-object-inheritance, - useless-super-delegation, [REPORTS] output-format = colorized diff --git a/src/molecule_podman/driver.py b/src/molecule_podman/driver.py index d037201..a554f41 100644 --- a/src/molecule_podman/driver.py +++ b/src/molecule_podman/driver.py @@ -155,7 +155,7 @@ class Podman(Driver): def __init__(self, config=None): """Construct Podman.""" - super(Podman, self).__init__(config) + super().__init__(config) self._name = "podman" # To change the podman executable, set environment variable # MOLECULE_PODMAN_EXECUTABLE @@ -205,7 +205,7 @@ def ansible_connection_options(self, instance_name): @cache def sanity_checks(self): """Implement Podman driver sanity checks.""" - log.info("Sanity checks: '{}'".format(self._name)) + log.info("Sanity checks: '%s'", self._name) # TODO(ssbarnea): reuse ansible runtime instance from molecule once it # fully adopts ansible-compat runtime = Runtime() diff --git a/src/molecule_podman/test/__init__.py b/src/molecule_podman/test/__init__.py index 8a443ad..bd880bd 100644 --- a/src/molecule_podman/test/__init__.py +++ b/src/molecule_podman/test/__init__.py @@ -1,5 +1 @@ """Driver tests.""" - -# TODO(ssbarnea): Use introspection to guess driver name - -DRIVER = "podman" diff --git a/src/molecule_podman/test/conftest.py b/src/molecule_podman/test/conftest.py index 3ed6326..9fa10d3 100644 --- a/src/molecule_podman/test/conftest.py +++ b/src/molecule_podman/test/conftest.py @@ -3,7 +3,6 @@ import platform import pytest -from molecule.test.conftest import random_string, temp_dir # noqa def pytest_collection_finish(session): @@ -15,6 +14,6 @@ def pytest_collection_finish(session): @pytest.fixture -def DRIVER(): +def driver_name() -> str: """Return name of the driver to be tested.""" return "podman" diff --git a/src/molecule_podman/test/test_driver.py b/src/molecule_podman/test/test_driver.py index 249b3f3..f584cf0 100644 --- a/src/molecule_podman/test/test_driver.py +++ b/src/molecule_podman/test/test_driver.py @@ -1,9 +1,7 @@ """Unit tests.""" from molecule import api -# from . import DRIVER - -def test_driver_is_detected(DRIVER): +def test_driver_is_detected(): """Asserts that molecule recognizes the driver.""" - assert DRIVER in [str(d) for d in api.drivers()] + assert any(str(d) == "podman" for d in api.drivers()) diff --git a/src/molecule_podman/test/test_func.py b/src/molecule_podman/test/test_func.py index bf24167..8d60fb3 100644 --- a/src/molecule_podman/test/test_func.py +++ b/src/molecule_podman/test/test_func.py @@ -21,7 +21,7 @@ def format_result(result: subprocess.CompletedProcess): ) -def test_command_init_scenario(tmp_path: pathlib.Path, DRIVER): +def test_command_init_scenario(tmp_path: pathlib.Path): """Verify that init scenario works.""" scenario_name = "default" @@ -33,7 +33,7 @@ def test_command_init_scenario(tmp_path: pathlib.Path, DRIVER): "scenario", scenario_name, "--driver-name", - DRIVER, + "podman", ] result = run_command(cmd) assert result.returncode == 0