Standardize Spyglass code with YAPF
From recently merged document updates in [0] there is a desire to standardize the Airship project python codebase. This is the effort to do so for the Spyglass project. [0] https://review.opendev.org/#/c/671291/ Co-Authored-By: Ian Pittwood <pittwoodian@gmail.com> Change-Id: I2b0f2491d83675d7742b168ecb9e1dfb9a11e719
This commit is contained in:
parent
534fe50b9e
commit
9689dae61f
10
.style.yapf
Normal file
10
.style.yapf
Normal file
@ -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
|
7
Makefile
7
Makefile
@ -63,7 +63,8 @@ lint: py_lint
|
|||||||
|
|
||||||
# Perform auto formatting
|
# Perform auto formatting
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
format: py_format
|
format:
|
||||||
|
tox -e fmt
|
||||||
|
|
||||||
_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,)
|
_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,)
|
||||||
|
|
||||||
@ -107,7 +108,3 @@ clean:
|
|||||||
.PHONY: py_lint
|
.PHONY: py_lint
|
||||||
py_lint:
|
py_lint:
|
||||||
tox -e pep8
|
tox -e pep8
|
||||||
|
|
||||||
.PHONY: py_format
|
|
||||||
py_format:
|
|
||||||
tox -e fmt
|
|
||||||
|
@ -9,3 +9,5 @@ netaddr==0.7.19
|
|||||||
pyrsistent==0.15.2
|
pyrsistent==0.15.2
|
||||||
pyyaml==5.1.1
|
pyyaml==5.1.1
|
||||||
six==1.12.0
|
six==1.12.0
|
||||||
|
yapf==0.27.0
|
||||||
|
flake8-import-order==0.18.1
|
||||||
|
@ -28,7 +28,6 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class ProcessDataSource(object):
|
class ProcessDataSource(object):
|
||||||
|
|
||||||
def __init__(self, site_type):
|
def __init__(self, site_type):
|
||||||
# Initialize intermediary and save site type
|
# Initialize intermediary and save site type
|
||||||
self._initialize_intermediary()
|
self._initialize_intermediary()
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
|
|
||||||
class BaseProcessor(object):
|
class BaseProcessor(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class SiteProcessor(BaseProcessor):
|
class SiteProcessor(BaseProcessor):
|
||||||
|
|
||||||
def __init__(self, site_data, manifest_dir, force_write):
|
def __init__(self, site_data, manifest_dir, force_write):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
if isinstance(site_data, SiteDocumentData):
|
if isinstance(site_data, SiteDocumentData):
|
||||||
|
37
tox.ini
37
tox.ini
@ -23,7 +23,7 @@ commands =
|
|||||||
[testenv:fmt]
|
[testenv:fmt]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps =
|
deps =
|
||||||
pipenv
|
pipenv
|
||||||
commands =
|
commands =
|
||||||
pipenv install --dev
|
pipenv install --dev
|
||||||
yapf -ir {toxinidir}/spyglass {toxinidir}/tests
|
yapf -ir {toxinidir}/spyglass {toxinidir}/tests
|
||||||
@ -36,7 +36,7 @@ deps =
|
|||||||
commands =
|
commands =
|
||||||
pipenv install --dev
|
pipenv install --dev
|
||||||
bash -c {toxinidir}/tools/gate/whitespace-linter.sh
|
bash -c {toxinidir}/tools/gate/whitespace-linter.sh
|
||||||
yapf -dr {toxinidir}/spyglass {toxinidir}/setup.py {toxinidir}/tests
|
yapf -dr {toxinidir}/spyglass {toxinidir}/tests
|
||||||
flake8 {toxinidir}/spyglass {toxinidir}/tests
|
flake8 {toxinidir}/spyglass {toxinidir}/tests
|
||||||
bandit -r spyglass -n 5
|
bandit -r spyglass -n 5
|
||||||
whitelist_externals =
|
whitelist_externals =
|
||||||
@ -55,40 +55,51 @@ commands =
|
|||||||
[testenv:bandit]
|
[testenv:bandit]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps =
|
deps =
|
||||||
pipenv
|
pipenv
|
||||||
commands =
|
commands =
|
||||||
pipenv install --dev
|
pipenv install --dev
|
||||||
bandit -r spyglass -n 5
|
bandit -r spyglass -n 5
|
||||||
|
|
||||||
[testenv:update-requirements]
|
[testenv:update-requirements]
|
||||||
deps =
|
deps =
|
||||||
pipenv
|
pipenv
|
||||||
commands =
|
commands =
|
||||||
pipenv lock --clear
|
pipenv lock --clear
|
||||||
bash -c "pipenv lock -r > {toxinidir}/requirements.txt"
|
bash -c "pipenv lock -r > {toxinidir}/requirements.txt"
|
||||||
whitelist_externals =
|
whitelist_externals =
|
||||||
bash
|
bash
|
||||||
|
|
||||||
[flake8]
|
|
||||||
ignore = W503
|
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps =
|
deps =
|
||||||
-r{toxinidir}/doc/requirements.txt
|
-r{toxinidir}/doc/requirements.txt
|
||||||
commands =
|
commands =
|
||||||
rm -rf doc/build
|
rm -rf doc/build
|
||||||
sphinx-build -b html doc/source doc/build/html -n -W -v
|
sphinx-build -b html doc/source doc/build/html -n -W -v
|
||||||
whitelist_externals = rm
|
whitelist_externals = rm
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps =
|
deps =
|
||||||
pipenv
|
pipenv
|
||||||
commands =
|
commands =
|
||||||
pipenv install --dev
|
pipenv install --dev
|
||||||
bash -c 'PATH=$PATH:~/.local/bin; pytest --cov=spyglass \
|
bash -c 'PATH=$PATH:~/.local/bin; pytest --cov=spyglass \
|
||||||
--cov-report html:cover --cov-report xml:cover/coverage.xml \
|
--cov-report html:cover --cov-report xml:cover/coverage.xml \
|
||||||
--cov-report term --cov-fail-under 88 tests/'
|
--cov-report term --cov-fail-under 88 tests/'
|
||||||
whitelist_externals =
|
whitelist_externals =
|
||||||
bash
|
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
|
||||||
|
import-order-style = pep8
|
||||||
|
Loading…
x
Reference in New Issue
Block a user