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/lint-requirements.txt b/lint-requirements.txt new file mode 100644 index 0000000000..da2426b8da --- /dev/null +++ b/lint-requirements.txt @@ -0,0 +1,2 @@ +flake8>=3.6.0,<4 +yamllint>=1.11.1,<2 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/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/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/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/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-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/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 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 50041dfa43..8dee8950c1 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,14 +34,33 @@ 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/ - +deps = yapf>=0.25.0,<2 +extras = +skip_install = true +tags = + format +usedevelop = false [testenv:format-check] commands = yapf -d -r molecule/ test/ - +deps = {[testenv:format]deps} +extras = {[testenv:format]extras} +skip_install = true +tags = + format +usedevelop = false [testenv:doc] passenv = * commands = @@ -101,18 +120,6 @@ tags = tags = unit -[testenv:py27-lint] -tags = - unit - -[testenv:py36-lint] -tags = - unit - -[testenv:py37-lint] -tags = - unit - [testenv:py27-ansible24-functional] tags = functional