From ae3227509c36ae4e6529fdc397933c8b2372c47a Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Thu, 18 Aug 2022 13:42:06 +0100 Subject: [PATCH] test_runner: revive flake8 --- .github/workflows/codestyle.yml | 3 +++ docs/sourcetree.md | 3 ++- poetry.lock | 40 ++++++++++++++++----------------- pre-commit.py | 11 +++++++++ pyproject.toml | 2 +- setup.cfg | 8 +++++++ 6 files changed, 45 insertions(+), 22 deletions(-) create mode 100644 setup.cfg diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index bd0f368499..029beba351 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -134,5 +134,8 @@ jobs: - name: Run black to ensure code format run: poetry run black --diff --check . + - name: Run flake8 to ensure code format + run: poetry run flake8 . + - name: Run mypy to check types run: poetry run mypy . diff --git a/docs/sourcetree.md b/docs/sourcetree.md index f189134865..88f4b0e559 100644 --- a/docs/sourcetree.md +++ b/docs/sourcetree.md @@ -118,6 +118,7 @@ Run the following commands in the repository's root (next to `pyproject.toml`): ```bash poetry run isort . # Imports are reformatted poetry run black . # All code is reformatted +poetry run flake8 . # Python linter poetry run mypy . # Ensure there are no typing errors ``` @@ -126,7 +127,7 @@ Otherwise it will not find its configuration. Also consider: -* Running `flake8` (or a linter of your choice, e.g. `pycodestyle`) and fixing possible defects, if any. +* Running `pycodestyle` (or a linter of your choice) and fixing possible defects, if any. * Adding more type hints to your code to avoid `Any`. ### Changing dependencies diff --git a/poetry.lock b/poetry.lock index cd24641a4f..e1f2e576eb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -653,16 +653,16 @@ testing = ["pre-commit"] [[package]] name = "flake8" -version = "3.9.2" +version = "5.0.4" description = "the modular source code checker: pep8 pyflakes and co" category = "dev" optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" +python-versions = ">=3.6.1" [package.dependencies] -mccabe = ">=0.6.0,<0.7.0" -pycodestyle = ">=2.7.0,<2.8.0" -pyflakes = ">=2.3.0,<2.4.0" +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.9.0,<2.10.0" +pyflakes = ">=2.5.0,<2.6.0" [[package]] name = "flask" @@ -870,11 +870,11 @@ python-versions = ">=3.7" [[package]] name = "mccabe" -version = "0.6.1" +version = "0.7.0" description = "McCabe checker, plugin for flake8" category = "dev" optional = false -python-versions = "*" +python-versions = ">=3.6" [[package]] name = "moto" @@ -1107,11 +1107,11 @@ python-versions = "*" [[package]] name = "pycodestyle" -version = "2.7.0" +version = "2.9.1" description = "Python style guide checker" category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +python-versions = ">=3.6" [[package]] name = "pycparser" @@ -1123,11 +1123,11 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "pyflakes" -version = "2.3.1" +version = "2.5.0" description = "passive checker of Python programs" category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +python-versions = ">=3.6" [[package]] name = "pyjwt" @@ -1537,7 +1537,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "497b963e7a2f80a751ccd201e950cf533caddb6c7c96163c94cea69874840843" +content-hash = "2112382a6723ed3b77d242db926c7445fa809fafcf11da127b5292565d2ba798" [metadata.files] aiopg = [ @@ -1759,8 +1759,8 @@ execnet = [ {file = "execnet-1.9.0.tar.gz", hash = "sha256:8f694f3ba9cc92cab508b152dcfe322153975c29bda272e2fd7f3f00f36e47c5"}, ] flake8 = [ - {file = "flake8-3.9.2-py2.py3-none-any.whl", hash = "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907"}, - {file = "flake8-3.9.2.tar.gz", hash = "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b"}, + {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"}, + {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"}, ] flask = [ {file = "Flask-2.1.3-py3-none-any.whl", hash = "sha256:9013281a7402ad527f8fd56375164f3aa021ecfaff89bfe3825346c24f87e04c"}, @@ -1872,8 +1872,8 @@ markupsafe = [ {file = "MarkupSafe-2.1.1.tar.gz", hash = "sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b"}, ] mccabe = [ - {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, - {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, ] moto = [ {file = "moto-3.1.18-py3-none-any.whl", hash = "sha256:b6eb096e7880c46ac44d6d90988c0043e31462115cfdc913a0ee8f470bd9555c"}, @@ -2026,16 +2026,16 @@ pyasn1 = [ {file = "pyasn1-0.4.8.tar.gz", hash = "sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba"}, ] pycodestyle = [ - {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"}, - {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"}, + {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"}, + {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"}, ] pycparser = [ {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, ] pyflakes = [ - {file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"}, - {file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"}, + {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"}, + {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, ] pyjwt = [ {file = "PyJWT-2.4.0-py3-none-any.whl", hash = "sha256:72d1d253f32dbd4f5c88eaf1fdc62f3a19f676ccbadb9dbc5d07e951b2b26daf"}, diff --git a/pre-commit.py b/pre-commit.py index 45f140d43a..560df6cd0c 100755 --- a/pre-commit.py +++ b/pre-commit.py @@ -50,6 +50,10 @@ def isort(fix_inplace: bool) -> str: return cmd +def flake8() -> str: + return "poetry run flake8" + + def mypy() -> str: return "poetry run mypy" @@ -122,6 +126,13 @@ if __name__ == "__main__": changed_files=files, no_color=args.no_color, ) + check( + name="flake8", + suffix=".py", + cmd=flake8(), + changed_files=files, + no_color=args.no_color, + ) check( name="mypy", suffix=".py", diff --git a/pyproject.toml b/pyproject.toml index 4f8a49a024..d648d1050a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ pytest-order = "^1.0.1" allure-pytest = "^2.9.45" [tool.poetry.dev-dependencies] -flake8 = "^3.9.2" +flake8 = "^5.0.4" mypy = "==0.971" black = "^22.6.0" isort = "^5.10.1" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000..a067ee731d --- /dev/null +++ b/setup.cfg @@ -0,0 +1,8 @@ +[flake8] +# Move config to pyproject.toml as soon as flake8 supports it +# https://github.com/PyCQA/flake8/issues/234 +extend-ignore = + E203, # Whitespace before ':' -- conflicts with black + E266, # Too many leading '#' for block comment -- we use it for formatting sometimes + E501 # Line too long -- black sorts it out +extend-exclude = vendor/