From 269ce7154f88a51e5dd9b883e2f7f15d5326a905 Mon Sep 17 00:00:00 2001 From: "Ian H. Pittwood" Date: Wed, 24 Jul 2019 13:22:31 -0500 Subject: [PATCH] Standardize spyglass-plugin-xls code with YAPF Implements documentation updates from [0] to standardize formatting for all Airship projects. [0] https://review.opendev.org/#/c/671291/ Change-Id: I723af0d91e24a306f05c06a3ddf456757489f7f0 --- .style.yapf | 10 ++++++++ setup.cfg | 8 ------ spyglass_plugin_xls/excel.py | 1 - spyglass_plugin_xls/excel_parser.py | 4 +-- test-requirements.txt | 2 ++ tox.ini | 39 ++++++++++++++++++----------- 6 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 .style.yapf diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 0000000..48dd95c --- /dev/null +++ b/.style.yapf @@ -0,0 +1,10 @@ +[style] +based_on_style = pep8 +spaces_before_comment = 2 +column_limit = 79 +blank_line_before_nested_class_or_def = false +blank_line_before_module_docstring = true +split_before_logical_operator = true +split_before_first_argument = true +allow_split_before_dict_value = false +split_before_arithmetic_operator = true \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 45677f6..22f90dd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,11 +22,3 @@ classifier = [files] packages = spyglass_plugin_xls - -[yapf] -based_on_style = pep8 -allow_split_before_dict_value = false -blank_line_before_nested_class_or_def = true -blank_line_before_module_docstring = true -split_before_logical_operator = false -split_before_first_argument = true \ No newline at end of file diff --git a/spyglass_plugin_xls/excel.py b/spyglass_plugin_xls/excel.py index c29fee4..bc60d9e 100644 --- a/spyglass_plugin_xls/excel.py +++ b/spyglass_plugin_xls/excel.py @@ -28,7 +28,6 @@ LOG = logging.getLogger(__name__) class ExcelPlugin(BaseDataSourcePlugin): - def __init__(self, region, **kwargs): super().__init__(region) LOG.info("Excel Plugin Initializing") diff --git a/spyglass_plugin_xls/excel_parser.py b/spyglass_plugin_xls/excel_parser.py index edc8a8a..ab9873b 100644 --- a/spyglass_plugin_xls/excel_parser.py +++ b/spyglass_plugin_xls/excel_parser.py @@ -14,11 +14,11 @@ from copy import deepcopy import logging +import pprint +import re from openpyxl import load_workbook from openpyxl import Workbook -import pprint -import re import yaml from spyglass_plugin_xls import exceptions diff --git a/test-requirements.txt b/test-requirements.txt index ed5a1e6..0a3d224 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,6 +4,8 @@ pytest-xdist==1.28.0 pytest-cov==2.6.1 # Formatting +flake8==3.7.8 +flake8-import-order==0.18.1 yapf==0.27.0 # Linting diff --git a/tox.ini b/tox.ini index 9a2959c..724368a 100644 --- a/tox.ini +++ b/tox.ini @@ -22,9 +22,9 @@ commands = [testenv:fmt] basepython = python3 deps = - -r{toxinidir}/test-requirements.txt + -r{toxinidir}/test-requirements.txt commands = - yapf -ir {toxinidir}/spyglass_plugin_xls {toxinidir}/setup.py {toxinidir}/tests + yapf -ir {toxinidir}/spyglass_plugin_xls {toxinidir}/setup.py {toxinidir}/tests [testenv:pep8] basepython = python3 @@ -41,29 +41,26 @@ whitelist_externals = [testenv:safety] basepython = python3 deps = - safety + safety commands = - safety check -r {toxinidir}/requirements.txt --full-report - safety check -r {toxinidir}/test-requirements.txt --full-report - safety check -r {toxinidir}/doc/requirements.txt --full-report + safety check -r {toxinidir}/requirements.txt --full-report + safety check -r {toxinidir}/test-requirements.txt --full-report + safety check -r {toxinidir}/doc/requirements.txt --full-report [testenv:bandit] basepython = python3 deps = - bandit + bandit commands = bandit -r spyglass_plugin_xls -n 5 -[flake8] -ignore = W503 - [testenv:docs] basepython = python3 deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/doc/requirements.txt + -r{toxinidir}/requirements.txt + -r{toxinidir}/doc/requirements.txt commands = - rm -rf doc/build - sphinx-build -b html doc/source doc/build -n -W -v + rm -rf doc/build + sphinx-build -b html doc/source doc/build -n -W -v whitelist_externals = rm [testenv:cover] @@ -77,3 +74,17 @@ commands = --cov-report term --cov-fail-under 92 tests/' whitelist_externals = bash + +[flake8] +filename = *.py +show-source = true +# [H106] Don't put vim configuration in source files. +# [H201] No 'except:' at least use 'except Exception:' +# [H904] Delay string interpolations at logging calls. +enable-extensions = H106,H201,H904 +# [W503] line break before binary operator +ignore = W503 +exclude=.venv,.git,.tox,build,dist,*lib/python*,*egg,tools,*.ini,*.po,*.pot +max-complexity = 24 +application-import-names = spyglass_plugin_xls +import-order-style = pep8