From b82985bff5d11c8815d7b72d3a2d0b7a94dcf89f Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Wed, 6 Jan 2021 07:19:40 +1100 Subject: [PATCH 1/2] Pull in latest cookiecutter updates - using spelling rather than pyspelling --- .pyspelling.yml | 89 ---------------- COOKIECUTTER_UPDATES.md | 4 +- app/.isort.cfg | 8 +- app/Dockerfile | 2 +- app/module_goes_here/__main__.py | 33 +++++- app/pip/2.7/test/requirements.txt | 2 +- app/pip/3.5/test/requirements.txt | 2 +- app/pip/3.6/test/requirements.txt | 2 +- app/pip/3.7/test/requirements.txt | 2 +- app/pip/3.8/spelling/requirements.txt | 5 +- app/pip/3.8/test/requirements.txt | 2 +- app/setup.py | 3 +- app/tests/test_main.py | 16 ++- ci/in_docker/test.sh | 6 +- docs/spelling_wordlist.txt | 140 +------------------------- 15 files changed, 64 insertions(+), 252 deletions(-) delete mode 100644 .pyspelling.yml diff --git a/.pyspelling.yml b/.pyspelling.yml deleted file mode 100644 index a54a4d4..0000000 --- a/.pyspelling.yml +++ /dev/null @@ -1,89 +0,0 @@ -spellchecker: aspell - -matrix: -- name: restructedtext - sources: - - ./**/*.rst - hunspell: - d: docs/spelling_wordlist.txt - aspell: - lang: en - dictionary: - wordlists: - - docs/spelling_wordlist.txt - output: build/dictionary/restructured.dic - pipeline: - - resplendent.filters.restructuredtext: - - pyspelling.filters.html: - comments: false - attributes: - - title - - alt - ignores: - - code - - pre - - pyspelling.filters.url: - -- name: markdown - sources: - - ./**/*.md - hunspell: - d: docs/spelling_wordlist.txt - aspell: - lang: en - dictionary: - wordlists: - - docs/spelling_wordlist.txt - output: build/dictionary/mkdocs.dic - pipeline: - - pyspelling.filters.markdown: - - pyspelling.filters.html: - comments: false - attributes: - - title - - alt - ignores: - - code - - pre - - pyspelling.filters.url: - -- name: python - sources: - - ./**/*.py - hunspell: - d: docs/src/dictionary/hunspell/en_AU - aspell: - lang: en - dictionary: - wordlists: - - docs/spelling_wordlist.txt - output: build/dictionary/python.dic - pipeline: - - pyspelling.filters.python: - group_comments: true - - pyspelling.flow_control.wildcard: - allow: - - py-comment - - pyspelling.filters.context: - context_visible_first: true - delimiters: - # Ignore lint (noqa) and coverage (pragma) as well as shebang (#!) - - open: '^(?: *(?:noqa\b|pragma: no cover)|!)' - close: '$' - # Ignore Python encoding string -*- encoding stuff -*- - - open: '^ *-\*-' - close: '-\*-$' - - pyspelling.filters.context: - context_visible_first: true - escapes: '\\[\\`]' - delimiters: - # Ignore multiline content between fences (fences can have 3 or more back ticks) - # ``` - # content - # ``` - - open: '(?s)^(?P *`{3,})$' - close: '^(?P=open)$' - # Ignore text between inline back ticks - - open: '(?P`+)' - close: '(?P=open)' - - pyspelling.filters.url: diff --git a/COOKIECUTTER_UPDATES.md b/COOKIECUTTER_UPDATES.md index 9f32ce6..a671b3f 100644 --- a/COOKIECUTTER_UPDATES.md +++ b/COOKIECUTTER_UPDATES.md @@ -8,7 +8,7 @@ consider application of new updates. # Updates from the Cookiecutter Template * Use an (Azure Pipelines)[https://azure.microsoft.com/en-au/services/devops/pipelines/] CI. * Follow (3Amigos)[https://3amigos-dev.github.io/] to use CI container pattern. -* Use (pyspelling)[https://github.com/facelessuser/pyspelling] to check spelling in CI. +* Use (spelling)[https://github.com/resplendent-dev/spelling] to check spelling in CI. * Use (flake8)[https://github.com/PyCQA/flake8] for static code analysis. * Use (bandit)[https://github.com/PyCQA/bandit] for security static analysis. * Use (pylint)[https://github.com/PyCQA/pylint] for static code analysis. @@ -20,7 +20,7 @@ consider application of new updates. * Use (pytest-cov)[https://github.com/pytest-dev/pytest-cov] to check 100% unit test coverage. * Use (pytest-xdist)[https://github.com/pytest-dev/pytest-xdist] for test parallelization. * Use (pytest-azurepipelines)[https://github.com/tonybaloney/pytest-azurepipelines] to publish tests results and coverage to Azure Pipelines Artifacts. -* Use (resplendent)[https://github.com/resplendent-dev/resplendent] to spell check reStructuredText in pyspelling. +* Use (resplendent)[https://github.com/resplendent-dev/resplendent] to spell check reStructuredText in spelling. * Use (shellcheck)[https://github.com/koalaman/shellcheck] for shell script static analysis. * Use (sphinx)[https://github.com/sphinx-doc/sphinx] for documentation generation. * Use (twine)[https://github.com/pypa/twine] for publishing to PyPI. diff --git a/app/.isort.cfg b/app/.isort.cfg index d4bb4fb..aed27d7 100644 --- a/app/.isort.cfg +++ b/app/.isort.cfg @@ -1,3 +1,5 @@ -[isort] -not_skip = __init__.py -line_length = 88 +[settings] +not_skip=__init__.py +line_length=88 +multi_line_output=3 +include_trailing_comma=yes diff --git a/app/Dockerfile b/app/Dockerfile index 18492d2..58ccc67 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,5 +1,5 @@ FROM 3amigos/pipenv-all:latest -ENV PYTHONVERS "2.7 3.5 3.6 3.7 3.8" +ENV PYTHONVERS "2.7 3.6 3.7 3.8" COPY install.sh /build/install.sh COPY pip /build/pip RUN /build/install.sh diff --git a/app/module_goes_here/__main__.py b/app/module_goes_here/__main__.py index 0bc58d0..f0a1cb3 100644 --- a/app/module_goes_here/__main__.py +++ b/app/module_goes_here/__main__.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python """ Module load handler for execution via: @@ -5,10 +6,35 @@ """ from __future__ import absolute_import, division, print_function, unicode_literals +import click -def main(): +CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) + +__version__ = "0.1" + + +@click.group(context_settings=CONTEXT_SETTINGS, invoke_without_command=True) +@click.version_option(version=__version__) +@click.pass_context +def main(ctxt): + """ + Main click group handler + """ + if ctxt.invoked_subcommand is None: + run_invocation() + + +@main.command() +def invoke(): + """ + Primary command handler + """ + run_invocation() + + +def run_invocation(): """ - Test + Execute the invocation """ print( """\ @@ -19,4 +45,5 @@ def main(): if __name__ == "__main__": - main() + main() # pylint: disable=no-value-for-parameter +# vim: set ft=python: diff --git a/app/pip/2.7/test/requirements.txt b/app/pip/2.7/test/requirements.txt index 0f634a0..0bb3f25 100644 --- a/app/pip/2.7/test/requirements.txt +++ b/app/pip/2.7/test/requirements.txt @@ -5,7 +5,7 @@ isort mock pylint pytest -pytest-azurepipelines42 +pytest-azurepipelines pytest-cov pytest-xdist safety diff --git a/app/pip/3.5/test/requirements.txt b/app/pip/3.5/test/requirements.txt index 0f634a0..0bb3f25 100644 --- a/app/pip/3.5/test/requirements.txt +++ b/app/pip/3.5/test/requirements.txt @@ -5,7 +5,7 @@ isort mock pylint pytest -pytest-azurepipelines42 +pytest-azurepipelines pytest-cov pytest-xdist safety diff --git a/app/pip/3.6/test/requirements.txt b/app/pip/3.6/test/requirements.txt index 0f634a0..0bb3f25 100644 --- a/app/pip/3.6/test/requirements.txt +++ b/app/pip/3.6/test/requirements.txt @@ -5,7 +5,7 @@ isort mock pylint pytest -pytest-azurepipelines42 +pytest-azurepipelines pytest-cov pytest-xdist safety diff --git a/app/pip/3.7/test/requirements.txt b/app/pip/3.7/test/requirements.txt index 0f634a0..0bb3f25 100644 --- a/app/pip/3.7/test/requirements.txt +++ b/app/pip/3.7/test/requirements.txt @@ -5,7 +5,7 @@ isort mock pylint pytest -pytest-azurepipelines42 +pytest-azurepipelines pytest-cov pytest-xdist safety diff --git a/app/pip/3.8/spelling/requirements.txt b/app/pip/3.8/spelling/requirements.txt index eec1eb2..e057d52 100644 --- a/app/pip/3.8/spelling/requirements.txt +++ b/app/pip/3.8/spelling/requirements.txt @@ -1,4 +1 @@ -pyspelling -wcmatch<5.0 -resplendent -unanimous +spelling diff --git a/app/pip/3.8/test/requirements.txt b/app/pip/3.8/test/requirements.txt index 0f634a0..0bb3f25 100644 --- a/app/pip/3.8/test/requirements.txt +++ b/app/pip/3.8/test/requirements.txt @@ -5,7 +5,7 @@ isort mock pylint pytest -pytest-azurepipelines42 +pytest-azurepipelines pytest-cov pytest-xdist safety diff --git a/app/setup.py b/app/setup.py index 6b40c70..62c21b8 100644 --- a/app/setup.py +++ b/app/setup.py @@ -64,7 +64,7 @@ def read_version(): .strip(), long_description=load_include("README.md", transform=True), long_description_content_type="text/markdown", - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", + python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", test_suite="tests", test_requires=[ elem.strip() @@ -85,7 +85,6 @@ def read_version(): "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", diff --git a/app/tests/test_main.py b/app/tests/test_main.py index ddb11fc..08e71b6 100644 --- a/app/tests/test_main.py +++ b/app/tests/test_main.py @@ -4,16 +4,22 @@ module_goes_here.__main__ """ +import pytest +from click.testing import CliRunner + from module_goes_here.__main__ import main -def test_main(): +@pytest.mark.parametrize("args,expected", [([], 0), (["invoke"], 0)]) +def test_main(args, expected): """ - GIVEN the .__main__ module entry point WHEN calling main THEN the call - executes successfully with a result of `None` + GIVEN the module_goes_here.__main__ + module entry point WHEN calling main THEN the call + executes successfully. """ # Setup + runner = CliRunner() # Exercise - result = main() # pylint: disable=assignment-from-no-return + result = runner.invoke(main, args) # Verify - assert result is None # nosec + assert result.exit_code == expected # nosec # noqa=S101 diff --git a/ci/in_docker/test.sh b/ci/in_docker/test.sh index e735a51..64d36f0 100755 --- a/ci/in_docker/test.sh +++ b/ci/in_docker/test.sh @@ -12,8 +12,8 @@ cd "${BASEDIR}" find . -iname \*.sh -print0 | xargs -0 shellcheck # Version independant checks PYVER=3.8 -# Run pyspelling in root to check docs -"python${PYVER}" -m pyspelling +# Run spelling in root to check docs +"python${PYVER}" -m spelling # Run black to check all python on 3.8 only "python${PYVER}" -m black --check --diff "${BASEDIR}" cd "${BASEDIR}/app" @@ -24,7 +24,7 @@ for PYVER in ${PYTHONVERS} ; do "python${PYVER}" -m bandit -r "${MODULES[@]}" find "${MODULES[@]}" -iname \*.py -print0 | xargs -0 -n 1 "${BASEDIR}/ci/in_docker/pylint.sh" "python${PYVER}" PYTEST_FAIL="NO" - if ! "python${PYVER}" -m pytest -n auto --cov-config=.coveragerc --cov-fail-under=100 "--cov=${MAIN_MODULE}" --cov-report=xml:test-cov.xml --cov-report=html ; then + if ! "python${PYVER}" -m pytest --cov-config=.coveragerc --cov-fail-under=100 "--cov=${MAIN_MODULE}" --cov-report=xml:test-cov.xml --cov-report=html --cov-report=term-missing ; then PYTEST_FAIL="YES" fi if [ ! -z "${TRAVIS_JOB_ID:-}" ] ; then diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 3915ded..0581400 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -1,135 +1,5 @@ -alldevices -allgroups -allprobes -allsensors -api -Appveyor -args -assignees -automodule -azurepipelines -backlink -beautifulsoup -BeautifulSoup -bs -Bugfixes -buildkite -BuildKite -byid -charset -CLI -cobertura -config -conftest -contrib -cookiecutter -CookieCutter -cov -css -datetime -defusedxml -dev -deviceid -deviceobj -deviceobject -dlint -docopt -DOCTYPE -docutils -exename -genindex -GitPython -GPLv -hh -hostname -href -html -http -https -iOS -ip -isort -javascript -Json -junit -JUnit -li -logdecorator -lt -lxml -maxdepth -md -modindex -newname -newplaceid -noqa -nosec -pademelon -pademelon -parallelization -param -params -passhash -pipefish -plumbum -pre -probeobject -prtg -prtgadmin -PRTGApi -PRTGDevice -PRTGSensor -py -PyEnchant -PyGithub -PyInquirer -pylint -PyPi -PyPI -pyruncompare -pyspelling -pytest -Pytest -pytest-buildkite -quickstart -rc -README -ReadTheDocs -repr -resplendent -restructuredtext -reStructuredText -rootid -rst -sensorid -sensorobject -sensortree -setuptools -sexualized -shellcheck -socio -ss -stdout -submodules -Submodules -sys -tcp -testsuite -th -toctree -towncrier -txt -ui -ul -unanimous -undoc -unicode -unmaintained -urls -utf -wcmatch -webgui -xdist -xml -yyyy -module_goes_here +custom +dictionary +words +go +here From 3fd7f340d0f72601a717284bc42a54a91bdfd5d4 Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Wed, 6 Jan 2021 07:22:50 +1100 Subject: [PATCH 2/2] Fix up other pip requirements for library change --- app/pip/3.6/spelling/requirements.txt | 2 +- app/pip/3.7/spelling/requirements.txt | 2 +- app/pip/3.9/spelling/requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/pip/3.6/spelling/requirements.txt b/app/pip/3.6/spelling/requirements.txt index eec1eb2..d4b7cd9 100644 --- a/app/pip/3.6/spelling/requirements.txt +++ b/app/pip/3.6/spelling/requirements.txt @@ -1,4 +1,4 @@ -pyspelling +spelling wcmatch<5.0 resplendent unanimous diff --git a/app/pip/3.7/spelling/requirements.txt b/app/pip/3.7/spelling/requirements.txt index eec1eb2..d4b7cd9 100644 --- a/app/pip/3.7/spelling/requirements.txt +++ b/app/pip/3.7/spelling/requirements.txt @@ -1,4 +1,4 @@ -pyspelling +spelling wcmatch<5.0 resplendent unanimous diff --git a/app/pip/3.9/spelling/requirements.txt b/app/pip/3.9/spelling/requirements.txt index eec1eb2..d4b7cd9 100644 --- a/app/pip/3.9/spelling/requirements.txt +++ b/app/pip/3.9/spelling/requirements.txt @@ -1,4 +1,4 @@ -pyspelling +spelling wcmatch<5.0 resplendent unanimous