From dfc6481541e74530935da137fbc29f61837889fd Mon Sep 17 00:00:00 2001 From: sebthom Date: Tue, 1 Feb 2022 06:46:22 +0100 Subject: [PATCH] add autopep8 source formatter --- .github/workflows/build.yml | 2 ++ README.md | 1 + pdm.lock | 25 ++++++++++++++++++++++++- pyproject.toml | 28 ++++++++++++++++++++++++++-- 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f42b19..88bc5d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,6 +69,8 @@ jobs: run: | pdm run lint + pdm run autopep8 -v --exit-code --recursive --diff kleinanzeigen_bot tests + - name: run unit tests run: | pdm run test diff --git a/README.md b/README.md index d5e3266..88e52c8 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,7 @@ updated_on: # set automatically > Please read [CONTRIBUTING.md](CONTRIBUTING.md) before contributing code. Thank you! +- Format source code: `pdm run format` - Running unit tests: `pdm run test` - Running linter: `pdm run lint` - Creating platform-specific executable: `pdm run compile` diff --git a/pdm.lock b/pdm.lock index 84cfaea..530d6d3 100644 --- a/pdm.lock +++ b/pdm.lock @@ -32,6 +32,15 @@ version = "21.4.0" requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" summary = "Classes Without Boilerplate" +[[package]] +name = "autopep8" +version = "1.6.0" +summary = "A tool that automatically formats Python code to conform to the PEP 8 style guide" +dependencies = [ + "pycodestyle>=2.8.0", + "toml", +] + [[package]] name = "bandit" version = "1.7.2" @@ -254,6 +263,12 @@ version = "1.11.0" requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" summary = "library with cross-python path, ini-parsing, io, code, log facilities" +[[package]] +name = "pycodestyle" +version = "2.8.0" +requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +summary = "Python style guide checker" + [[package]] name = "pycparser" version = "2.21" @@ -522,7 +537,7 @@ dependencies = [ [metadata] lock_version = "3.1" -content_hash = "sha256:92d73225adbc3f8c9e16ea26f15a46a8edb985480a6ce601023aed3ed5336f05" +content_hash = "sha256:774c08638da83171a24511eb8eecb055bc0b09bd5b38263118dd8ac32b842bdd" [metadata.files] "altgraph 0.17.2" = [ @@ -545,6 +560,10 @@ content_hash = "sha256:92d73225adbc3f8c9e16ea26f15a46a8edb985480a6ce601023aed3ed {file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"}, {file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"}, ] +"autopep8 1.6.0" = [ + {file = "autopep8-1.6.0-py2.py3-none-any.whl", hash = "sha256:ed77137193bbac52d029a52c59bec1b0629b5a186c495f1eb21b126ac466083f"}, + {file = "autopep8-1.6.0.tar.gz", hash = "sha256:44f0932855039d2c15c4510d6df665e4730f2b8582704fa48f9c55bd3e17d979"}, +] "bandit 1.7.2" = [ {file = "bandit-1.7.2-py3-none-any.whl", hash = "sha256:e20402cadfd126d85b68ed4c8862959663c8c372dbbb1fca8f8e2c9f55a067ec"}, {file = "bandit-1.7.2.tar.gz", hash = "sha256:6d11adea0214a43813887bfe71a377b5a9955e4c826c8ffd341b494e3ab25260"}, @@ -816,6 +835,10 @@ content_hash = "sha256:92d73225adbc3f8c9e16ea26f15a46a8edb985480a6ce601023aed3ed {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] +"pycodestyle 2.8.0" = [ + {file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"}, + {file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"}, +] "pycparser 2.21" = [ {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, diff --git a/pyproject.toml b/pyproject.toml index 39b20ba..649d938 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,8 @@ dependencies = [ "pywin32==303; sys_platform == 'win32'", "selenium~=4.1", "selenium_stealth~=1.0", - "webdriver_manager~=3.5"] + "webdriver_manager~=3.5" +] [project.urls] homepage = "https://github.com/Second-Hand-Friends/kleinanzeigen-bot" @@ -56,6 +57,7 @@ version = {use_scm = true} [tool.pdm.dev-dependencies] dev = [ + "autopep8~=1.6.0", "bandit~=1.7", "pytest~=6.2", "pyinstaller~=4.8", @@ -67,19 +69,40 @@ dev = [ [tool.pdm.scripts] app = "python -m kleinanzeigen_bot" compile = "python -O -m PyInstaller pyinstaller.spec --clean" +format = "autopep8 --recursive --in-place kleinanzeigen_bot tests" lint = "pylint kleinanzeigen_bot" scan = "bandit -c pyproject.toml -r kleinanzeigen_bot" test = "python -m pytest -v" ##################### -# bandit https://github.com/PyCQA/bandit +# autopep8 +# https://pypi.org/project/autopep8/ +# https://github.com/hhatto/autopep8 +##################### +[tool.autopep8] +max_line_length = 160 +ignore = [ # https://github.com/hhatto/autopep8#features + "E124", # Don't change indention of multi-line statements + "E128", # Don't change indention of multi-line statements + "E231", # Don't add whitespace after colon (:) on type declaration + "E251", # Don't remove whitespace around parameter '=' sign. + "E401" # Don't put imports on separate lines +] +aggressive = 3 + +##################### +# bandit +# https://pypi.org/project/bandit/ +# https://github.com/PyCQA/bandit ##################### [tool.bandit] ##################### # pylint +# https://pypi.org/project/pylint/ +# https://github.com/PyCQA/pylint ##################### [tool.pylint.master] extension-pkg-whitelist = "win32api" @@ -120,6 +143,7 @@ max-statements = 70 ##################### # pytest +# https://pypi.org/project/pytest/ ##################### [tool.pytest.ini_options] # https://docs.pytest.org/en/stable/reference.html#confval-addopts