From cda8721a3c81e7bef7a6612172da24a190ab7616 Mon Sep 17 00:00:00 2001 From: Fabrice Flore-Thebault Date: Wed, 23 Jan 2019 15:44:09 +0100 Subject: [PATCH 1/7] 1694 lint errors Signed-off-by: Fabrice Flore-Thebault --- lint-requirements.txt | 2 ++ molecule/dependency/shell.py | 4 ++-- molecule/interpolation.py | 4 ++-- molecule/provisioner/ansible_playbook.py | 4 ++-- molecule/verifier/goss.py | 4 ++-- molecule/verifier/testinfra.py | 3 ++- tox.ini | 15 ++++++++++++--- 7 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 lint-requirements.txt diff --git a/lint-requirements.txt b/lint-requirements.txt new file mode 100644 index 0000000000..29460f4901 --- /dev/null +++ b/lint-requirements.txt @@ -0,0 +1,2 @@ +flake8==3.5.0 +yamllint>=1.11.1,<2 diff --git a/molecule/dependency/shell.py b/molecule/dependency/shell.py index b4b15d6bf9..e5fed5c262 100644 --- a/molecule/dependency/shell.py +++ b/molecule/dependency/shell.py @@ -34,8 +34,8 @@ class Shell(base.Base): ``Shell`` is an alternate dependency manager. It is intended to run a command in situations where `Ansible Galaxy`_ and `Gilt`_ don't suffice. - The ``command`` to execute is required, and is relative to Molecule's project - directory when referencing a script not in $PATH. + The ``command`` to execute is required, and is relative to Molecule's + project directory when referencing a script not in $PATH. .. note:: diff --git a/molecule/interpolation.py b/molecule/interpolation.py index e5f5de7e20..94a1bf03af 100644 --- a/molecule/interpolation.py +++ b/molecule/interpolation.py @@ -50,8 +50,8 @@ class Interpolator(object): If a literal dollar sign is needed in a configuration, use a double dollar sign (`$$`). - Molecule will substitute special ``MOLECULE_`` environment variables defined - in `molecule.yml`. + Molecule will substitute special ``MOLECULE_`` environment variables + defined in `molecule.yml`. .. important:: diff --git a/molecule/provisioner/ansible_playbook.py b/molecule/provisioner/ansible_playbook.py index a29948e3a0..120b2bba18 100644 --- a/molecule/provisioner/ansible_playbook.py +++ b/molecule/provisioner/ansible_playbook.py @@ -50,8 +50,8 @@ def __init__(self, playbook, config, out=LOG.out, err=LOG.error): def bake(self): """ - Bake an ``ansible-playbook`` command so it's ready to execute and returns - None. + Bake an ``ansible-playbook`` command so it's ready to execute and + returns None. :return: None """ diff --git a/molecule/verifier/goss.py b/molecule/verifier/goss.py index 64fc9663c0..1cbacb3fa4 100644 --- a/molecule/verifier/goss.py +++ b/molecule/verifier/goss.py @@ -39,8 +39,8 @@ class Goss(base.Base): and execute Goss using a community written Goss Ansible module bundled with Molecule. - Additional options can be passed to ``goss validate`` by modifying the verify - playbook. + Additional options can be passed to ``goss validate`` by modifying the + verify playbook. .. code-block:: yaml diff --git a/molecule/verifier/testinfra.py b/molecule/verifier/testinfra.py index fd879719b6..a6ea979a46 100644 --- a/molecule/verifier/testinfra.py +++ b/molecule/verifier/testinfra.py @@ -40,7 +40,8 @@ class Testinfra(base.Base): .. note:: Molecule will remove any options matching '^[v]+$', and pass ``-vvv`` - to the underlying ``py.test`` command when executing ``molecule --debug``. + to the underlying ``py.test`` command when executing + ``molecule --debug``. .. code-block:: yaml diff --git a/tox.ini b/tox.ini index 50041dfa43..6d87ca4c89 100644 --- a/tox.ini +++ b/tox.ini @@ -102,16 +102,25 @@ tags = unit [testenv:py27-lint] +deps = + -rlint-requirements.txt +skip_install = true tags = - unit + lint [testenv:py36-lint] +deps = + -rlint-requirements.txt +skip_install = true tags = - unit + lint [testenv:py37-lint] +deps = + -rlint-requirements.txt +skip_install = true tags = - unit + lint [testenv:py27-ansible24-functional] tags = From f943de73e23f75ce880e39c165ee127af87c6135 Mon Sep 17 00:00:00 2001 From: Fabrice Flore-Thebault Date: Mon, 28 Jan 2019 16:46:03 +0100 Subject: [PATCH 2/7] fixes #1694, reimplement #1574 - fix linting issues, upgrade flake8 to 3.6.0, make sure the versions of the packages are defined only in one single place. Signed-off-by: Fabrice Flore-Thebault --- lint-requirements.txt | 2 +- molecule/driver/base.py | 4 ++-- molecule/shell.py | 8 ++++---- requirements.txt | 3 +-- test/functional/docker/test_scenarios.py | 6 +++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lint-requirements.txt b/lint-requirements.txt index 29460f4901..da2426b8da 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -1,2 +1,2 @@ -flake8==3.5.0 +flake8>=3.6.0,<4 yamllint>=1.11.1,<2 diff --git a/molecule/driver/base.py b/molecule/driver/base.py index ea70c2240f..f37232aeb4 100644 --- a/molecule/driver/base.py +++ b/molecule/driver/base.py @@ -136,8 +136,8 @@ def ssh_connection_options(self): @property def safe_files(self): - return (self.default_safe_files + - self._config.config['driver']['safe_files']) + return (self.default_safe_files + + self._config.config['driver']['safe_files']) @property def delegated(self): diff --git a/molecule/shell.py b/molecule/shell.py index 5ac677a6c7..b378fdf6ef 100644 --- a/molecule/shell.py +++ b/molecule/shell.py @@ -54,8 +54,8 @@ def _supported_python3_version(): # pragma: no cover def _supported_ansible_version(): # pragma: no cover - if (distutils.version.LooseVersion(_get_ansible_version()) <= - distutils.version.LooseVersion('2.4')): + if (distutils.version.LooseVersion(_get_ansible_version()) + <= distutils.version.LooseVersion('2.4')): msg = ("Ansible version '{}' not supported. " 'Molecule only supports Ansible versions ' "'>= 2.4'.").format(_get_ansible_version()) @@ -64,8 +64,8 @@ def _supported_ansible_version(): # pragma: no cover if _supported_python2_version(): pass elif _supported_python3_version(): - if (distutils.version.LooseVersion(_get_ansible_version()) < - distutils.version.LooseVersion('2.4')): + if (distutils.version.LooseVersion(_get_ansible_version()) + < distutils.version.LooseVersion('2.4')): msg = ("Ansible version '{}' not supported. " 'Molecule only supports Ansible versions ' "'>=2.5' with Python version '{}'").format( diff --git a/requirements.txt b/requirements.txt index 6d1b066793..c20294d944 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +-r lint-requirements.txt ansible-lint>=4.0.1,<5 anyconfig==0.9.7 cerberus==1.2 @@ -5,7 +6,6 @@ click==6.7 click-completion==0.3.1 colorama==0.3.9 cookiecutter==1.6.0 -flake8==3.5.0 idna<2.8 # because indirect dependency "requests" conflict with it now python-gilt==1.2.1 Jinja2==2.10 @@ -18,4 +18,3 @@ six==1.11.0 tabulate==0.8.2 testinfra==1.16.0 tree-format==0.1.2 -yamllint==1.11.1 diff --git a/test/functional/docker/test_scenarios.py b/test/functional/docker/test_scenarios.py index 1c319bc324..72bb1391cd 100644 --- a/test/functional/docker/test_scenarios.py +++ b/test/functional/docker/test_scenarios.py @@ -349,9 +349,9 @@ def test_host_group_vars(scenario_to_test, with_scenario, scenario_name): out = pytest.helpers.run_command(cmd, log=False) out = util.strip_ansi_escape(out.stdout.decode('utf-8')) - assert re.search('\[all\].*?ok: \[instance\]', out, re.DOTALL) - assert re.search('\[example\].*?ok: \[instance\]', out, re.DOTALL) - assert re.search('\[example_1\].*?ok: \[instance\]', out, re.DOTALL) + assert re.search(r'\[all\].*?ok: \[instance\]', out, re.DOTALL) + assert re.search(r'\[example\].*?ok: \[instance\]', out, re.DOTALL) + assert re.search(r'\[example_1\].*?ok: \[instance\]', out, re.DOTALL) @skip_unsupported_matrix From 22496b78cdc4773ebe0343eca3db3f1b9089f3e8 Mon Sep 17 00:00:00 2001 From: Fabrice Flore-Thebault Date: Tue, 29 Jan 2019 09:43:55 +0100 Subject: [PATCH 3/7] fix #1694 lint errors - excluding rule [W504] line break after binary operator, as latest version of yapf is in conflict with this rule, see https://github.com/google/yapf/issues/658. Signed-off-by: Fabrice Flore-Thebault --- .flake8 | 2 +- =0.25.0,2 | 1 + molecule/command/matrix.py | 3 +-- molecule/driver/base.py | 4 ++-- molecule/shell.py | 8 ++++---- molecule/util.py | 5 +++-- test-requirements.txt | 2 +- .../multi-node/tests/test_instance-1.py | 4 ++-- .../multi-node/tests/test_instance-2.py | 4 ++-- tox.ini | 20 +++++++++++++++++-- 10 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 =0.25.0,2 diff --git a/.flake8 b/.flake8 index 2624e1e509..dda1d77cdf 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] exclude = .venv/,.tox/,dist/,build/,doc/,.eggs/,molecule/provisioner/ansible/plugins/libraries/goss.py format = pylint -ignore = E741,W503 +ignore = E741,W503,W504 diff --git a/=0.25.0,2 b/=0.25.0,2 new file mode 100644 index 0000000000..441cf39670 --- /dev/null +++ b/=0.25.0,2 @@ -0,0 +1 @@ +Requirement already satisfied: yapf in /home/fft/Envs/molecule/lib/python2.7/site-packages (0.21.0) diff --git a/molecule/command/matrix.py b/molecule/command/matrix.py index 127c94b88a..c9c176758e 100644 --- a/molecule/command/matrix.py +++ b/molecule/command/matrix.py @@ -67,8 +67,7 @@ class Matrix(base.Base): @click.option('--scenario-name', '-s', help='Name of the scenario to target.') # NOTE(retr0h): Cannot introspect base.Base for `click.Choice`, since # subclasses have not all loaded at this point. -@click.argument( - 'subcommand', nargs=1, type=click.UNPROCESSED) +@click.argument('subcommand', nargs=1, type=click.UNPROCESSED) def matrix(ctx, scenario_name, subcommand): # pragma: no cover """ List matrix of steps used to test instances. diff --git a/molecule/driver/base.py b/molecule/driver/base.py index f37232aeb4..ea70c2240f 100644 --- a/molecule/driver/base.py +++ b/molecule/driver/base.py @@ -136,8 +136,8 @@ def ssh_connection_options(self): @property def safe_files(self): - return (self.default_safe_files - + self._config.config['driver']['safe_files']) + return (self.default_safe_files + + self._config.config['driver']['safe_files']) @property def delegated(self): diff --git a/molecule/shell.py b/molecule/shell.py index b378fdf6ef..5ac677a6c7 100644 --- a/molecule/shell.py +++ b/molecule/shell.py @@ -54,8 +54,8 @@ def _supported_python3_version(): # pragma: no cover def _supported_ansible_version(): # pragma: no cover - if (distutils.version.LooseVersion(_get_ansible_version()) - <= distutils.version.LooseVersion('2.4')): + if (distutils.version.LooseVersion(_get_ansible_version()) <= + distutils.version.LooseVersion('2.4')): msg = ("Ansible version '{}' not supported. " 'Molecule only supports Ansible versions ' "'>= 2.4'.").format(_get_ansible_version()) @@ -64,8 +64,8 @@ def _supported_ansible_version(): # pragma: no cover if _supported_python2_version(): pass elif _supported_python3_version(): - if (distutils.version.LooseVersion(_get_ansible_version()) - < distutils.version.LooseVersion('2.4')): + if (distutils.version.LooseVersion(_get_ansible_version()) < + distutils.version.LooseVersion('2.4')): msg = ("Ansible version '{}' not supported. " 'Molecule only supports Ansible versions ' "'>=2.5' with Python version '{}'").format( diff --git a/molecule/util.py b/molecule/util.py index e45d443c1b..1c64367502 100644 --- a/molecule/util.py +++ b/molecule/util.py @@ -73,8 +73,9 @@ def print_environment_vars(env): combined_env = ansible_env.copy() combined_env.update(molecule_env) - print_debug('SHELL REPLAY', " ".join( - ["{}={}".format(k, v) for (k, v) in sorted(combined_env.items())])) + print_debug( + 'SHELL REPLAY', " ".join( + ["{}={}".format(k, v) for (k, v) in sorted(combined_env.items())])) print() diff --git a/test-requirements.txt b/test-requirements.txt index 7ed267c35f..079d002c5b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -10,5 +10,5 @@ pytest-xdist==1.26.0 shade==1.22.2 twine wheel==0.30.0 -yapf==0.21.0 +yapf>=0.25.0,<2 https://github.com/AndreLouisCaron/tox-tags/archive/master.zip#egg=tox-tags diff --git a/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-1.py b/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-1.py index 668baa6ab9..b7ded3e12c 100644 --- a/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-1.py +++ b/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-1.py @@ -19,8 +19,8 @@ def test_cpus(host): def test_memory(host): - total_memory = host.ansible("setup")['ansible_facts'][ - 'ansible_memtotal_mb'] + total_memory = host.ansible( + "setup")['ansible_facts']['ansible_memtotal_mb'] assert (1024 / 2) <= int(total_memory) <= 1024 diff --git a/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-2.py b/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-2.py index 7dc9da886e..c72f74d738 100644 --- a/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-2.py +++ b/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-2.py @@ -19,8 +19,8 @@ def test_cpus(host): def test_memory(host): - total_memory = host.ansible("setup")['ansible_facts'][ - 'ansible_memtotal_mb'] + total_memory = host.ansible( + "setup")['ansible_facts']['ansible_memtotal_mb'] assert (1024 + 1024 / 2) <= int(total_memory) <= 2048 diff --git a/tox.ini b/tox.ini index 6d87ca4c89..38fb7a53b4 100644 --- a/tox.ini +++ b/tox.ini @@ -37,11 +37,21 @@ commands = [testenv:format] commands = yapf -i -r molecule/ test/ - +deps = yapf>=0.25.0,<2 +extras = [] +skip_install = true +tags = + format +usedevelop = false [testenv:format-check] commands = yapf -d -r molecule/ test/ - +deps = yapf>=0.25.0,<2 +extras = [] +skip_install = true +tags = + format +usedevelop = false [testenv:doc] passenv = * commands = @@ -104,23 +114,29 @@ tags = [testenv:py27-lint] deps = -rlint-requirements.txt +extras = [] skip_install = true tags = lint +usedevelop = false [testenv:py36-lint] deps = -rlint-requirements.txt +extras = [] skip_install = true tags = lint +usedevelop = false [testenv:py37-lint] deps = -rlint-requirements.txt +extras = [] skip_install = true tags = lint +usedevelop = false [testenv:py27-ansible24-functional] tags = From a84f4bc56e953c3a6f08a2758f5ee66f10e4fb0b Mon Sep 17 00:00:00 2001 From: Fabrice Flore-Thebault Date: Tue, 29 Jan 2019 09:53:10 +0100 Subject: [PATCH 4/7] fix #1694 lint errors - travis is using 'lint', not 'py{27,36,37}-lint', so cleanup the tox.ini Signed-off-by: Fabrice Flore-Thebault --- tox.ini | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/tox.ini b/tox.ini index 38fb7a53b4..8fa88e3f3f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] minversion = 3.7.0 envlist = + lint py{27,36,37}-ansible{24,25,26,27}-{functional,unit} - py{27,36,37}-lint format-check doc skipdist = True @@ -34,6 +34,15 @@ commands = lint: flake8 lint: yamllint -s test/ molecule/ +[testenv:lint] +deps = + -rlint-requirements.txt +extras = [] +skip_install = true +tags = + lint +usedevelop = false + [testenv:format] commands = yapf -i -r molecule/ test/ @@ -111,33 +120,6 @@ tags = tags = unit -[testenv:py27-lint] -deps = - -rlint-requirements.txt -extras = [] -skip_install = true -tags = - lint -usedevelop = false - -[testenv:py36-lint] -deps = - -rlint-requirements.txt -extras = [] -skip_install = true -tags = - lint -usedevelop = false - -[testenv:py37-lint] -deps = - -rlint-requirements.txt -extras = [] -skip_install = true -tags = - lint -usedevelop = false - [testenv:py27-ansible24-functional] tags = functional From d9d532cc4f47f2c3ec79e56bb9d2cb88d7e92694 Mon Sep 17 00:00:00 2001 From: Fabrice Flore-Thebault Date: Tue, 29 Jan 2019 10:01:52 +0100 Subject: [PATCH 5/7] remove file commited by error Signed-off-by: Fabrice Flore-Thebault --- =0.25.0,2 | 1 - 1 file changed, 1 deletion(-) delete mode 100644 =0.25.0,2 diff --git a/=0.25.0,2 b/=0.25.0,2 deleted file mode 100644 index 441cf39670..0000000000 --- a/=0.25.0,2 +++ /dev/null @@ -1 +0,0 @@ -Requirement already satisfied: yapf in /home/fft/Envs/molecule/lib/python2.7/site-packages (0.21.0) From afaca844928cc5d313ebedb417edb3ae2d97300f Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Tue, 29 Jan 2019 13:29:38 +0100 Subject: [PATCH 6/7] Update tox.ini Co-Authored-By: themr0c --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 8fa88e3f3f..e5a1195d03 100644 --- a/tox.ini +++ b/tox.ini @@ -56,7 +56,7 @@ usedevelop = false commands = yapf -d -r molecule/ test/ deps = yapf>=0.25.0,<2 -extras = [] +extras = skip_install = true tags = format From da427d9e19f9b690a6e03cbb4d6c9d240dbd69fd Mon Sep 17 00:00:00 2001 From: Fabrice Flore-Thebault Date: Wed, 30 Jan 2019 14:13:40 +0100 Subject: [PATCH 7/7] reuse deps and extras Signed-off-by: Fabrice Flore-Thebault --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index e5a1195d03..8dee8950c1 100644 --- a/tox.ini +++ b/tox.ini @@ -47,7 +47,7 @@ usedevelop = false commands = yapf -i -r molecule/ test/ deps = yapf>=0.25.0,<2 -extras = [] +extras = skip_install = true tags = format @@ -55,8 +55,8 @@ usedevelop = false [testenv:format-check] commands = yapf -d -r molecule/ test/ -deps = yapf>=0.25.0,<2 -extras = +deps = {[testenv:format]deps} +extras = {[testenv:format]extras} skip_install = true tags = format