diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 6672101b30..33e8ba5c97 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -25,7 +25,7 @@ on: jobs: # Lint checks which don't depend on any service containes, etc. to be running. lint-checks: - name: 'Lint Checks (pants runs: shellcheck, black)' + name: 'Lint Checks (pants runs: shellcheck, black, flake8)' runs-on: ubuntu-latest env: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 672042a389..bd011605f5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -53,7 +53,7 @@ Added * Begin introducing `pants `_ to improve DX (Developer Experience) working on StackStorm, improve our security posture, and improve CI reliability thanks in part - to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725 #5732 #5733 #5737 #5738 #5758 #5751 #5774 + to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725 #5732 #5733 #5737 #5738 #5758 #5751 #5774 #5776 Contributed by @cognifloyd Changed diff --git a/lockfiles/flake8.lock b/lockfiles/flake8.lock new file mode 100644 index 0000000000..6b107cdcef --- /dev/null +++ b/lockfiles/flake8.lock @@ -0,0 +1,349 @@ +// This lockfile was autogenerated by Pants. To regenerate, run: +// +// ./pants generate-lockfiles --resolve=flake8 +// +// --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE --- +// { +// "version": 3, +// "valid_for_interpreter_constraints": [ +// "CPython<4,>=3.7" +// ], +// "generated_with_requirements": [ +// "flake8==4.0.1", +// "st2flake8==0.1.0" +// ], +// "manylinux": "manylinux2014", +// "requirement_constraints": [], +// "only_binary": [], +// "no_binary": [] +// } +// --- END PANTS LOCKFILE METADATA --- + +{ + "allow_builds": true, + "allow_prereleases": false, + "allow_wheels": true, + "build_isolation": true, + "constraints": [], + "locked_resolves": [ + { + "locked_requirements": [ + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d", + "url": "https://files.pythonhosted.org/packages/34/39/cde2c8a227abb4f9ce62fe55586b920f438f1d2903a1a22514d0b982c333/flake8-4.0.1-py2.py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d", + "url": "https://files.pythonhosted.org/packages/e6/84/d8db922289195c435779b4ca3a3f583f263f87e67954f7b2e83c8da21f48/flake8-4.0.1.tar.gz" + } + ], + "project_name": "flake8", + "requires_dists": [ + "importlib-metadata<4.3; python_version < \"3.8\"", + "mccabe<0.7.0,>=0.6.0", + "pycodestyle<2.9.0,>=2.8.0", + "pyflakes<2.5.0,>=2.4.0" + ], + "requires_python": ">=3.6", + "version": "4.0.1" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "dbad92ee5f51398722cd571b6e36cc3651914bf1b286b0e638bba1f4af0b6f5b", + "url": "https://files.pythonhosted.org/packages/af/9c/a8ad17f373dfad4c0fea345290ef8ce54d63b76a3166d6bb57030d7a6d59/flake8_copyright-0.2.2-py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "616a960c9602ad2d0136bf3f12564e253caffe82f151d2982f78a12a42e1faa0", + "url": "https://files.pythonhosted.org/packages/17/83/19b630889d8c3291a04ddb6ab5bf691618a07a11be239c15f2b524708b93/flake8_copyright-0.2.2-py2.py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "5c3632dd8c586547b25fff4272282005fdbcba56eeb77b7487564aa636b6e533", + "url": "https://files.pythonhosted.org/packages/66/35/3a5712611f8345329582817c71db68f6a1b6f4d500efeaeca1137b241417/flake8-copyright-0.2.2.tar.gz" + } + ], + "project_name": "flake8-copyright", + "requires_dists": [ + "setuptools" + ], + "requires_python": null, + "version": "0.2.2" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9", + "url": "https://files.pythonhosted.org/packages/86/b5/a43fed6fd0193585d17d6faa7b85317d4461f694aaed546098c69f856579/flake8_polyfill-1.0.2-py2.py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda", + "url": "https://files.pythonhosted.org/packages/e6/67/1c26634a770db5c442e361311bee73cb3a177adb2eb3f7af8953cfd9f553/flake8-polyfill-1.0.2.tar.gz" + } + ], + "project_name": "flake8-polyfill", + "requires_dists": [ + "flake8" + ], + "requires_python": null, + "version": "1.0.2" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "057e92c15bc8d9e8109738a48db0ccb31b4d9d5cfbee5a8670879a30be66304b", + "url": "https://files.pythonhosted.org/packages/22/51/52442c59db26637681148c21f8984eed58c9db67053a0a4783a047010c98/importlib_metadata-4.2.0-py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "b7e52a1f8dec14a75ea73e0891f3060099ca1d8e6a462a4dff11c3e119ea1b31", + "url": "https://files.pythonhosted.org/packages/c7/7c/126a8686399ebe256b5e4343ea80b6f2ee91549969da2eef0bb2891b8d24/importlib_metadata-4.2.0.tar.gz" + } + ], + "project_name": "importlib-metadata", + "requires_dists": [ + "flufl.flake8; extra == \"testing\"", + "importlib-resources>=1.3; python_version < \"3.9\" and extra == \"testing\"", + "jaraco.packaging>=8.2; extra == \"docs\"", + "packaging; extra == \"testing\"", + "pep517; extra == \"testing\"", + "pyfakefs; extra == \"testing\"", + "pytest-black>=0.3.7; (platform_python_implementation != \"PyPy\" and python_version < \"3.10\") and extra == \"testing\"", + "pytest-checkdocs>=2.4; extra == \"testing\"", + "pytest-cov; extra == \"testing\"", + "pytest-enabler>=1.0.1; extra == \"testing\"", + "pytest-flake8; extra == \"testing\"", + "pytest-mypy; (platform_python_implementation != \"PyPy\" and python_version < \"3.10\") and extra == \"testing\"", + "pytest>=4.6; extra == \"testing\"", + "rst.linker>=1.9; extra == \"docs\"", + "sphinx; extra == \"docs\"", + "typing-extensions>=3.6.4; python_version < \"3.8\"", + "zipp>=0.5" + ], + "requires_python": ">=3.6", + "version": "4.2" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "url": "https://files.pythonhosted.org/packages/87/89/479dc97e18549e21354893e4ee4ef36db1d237534982482c3681ee6e7b57/mccabe-0.6.1-py2.py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f", + "url": "https://files.pythonhosted.org/packages/06/18/fa675aa501e11d6d6ca0ae73a101b2f3571a565e0f7d38e062eec18a91ee/mccabe-0.6.1.tar.gz" + } + ], + "project_name": "mccabe", + "requires_dists": [], + "requires_python": null, + "version": "0.6.1" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20", + "url": "https://files.pythonhosted.org/packages/15/94/bc43a2efb7b8615e38acde2b6624cae8c9ec86faf718ff5676c5179a7714/pycodestyle-2.8.0-py2.py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f", + "url": "https://files.pythonhosted.org/packages/08/dc/b29daf0a202b03f57c19e7295b60d1d5e1281c45a6f5f573e41830819918/pycodestyle-2.8.0.tar.gz" + } + ], + "project_name": "pycodestyle", + "requires_dists": [], + "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7", + "version": "2.8" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e", + "url": "https://files.pythonhosted.org/packages/43/fb/38848eb494af7df9aeb2d7673ace8b213313eb7e391691a79dbaeb6a838f/pyflakes-2.4.0-py2.py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c", + "url": "https://files.pythonhosted.org/packages/15/60/c577e54518086e98470e9088278247f4af1d39cb43bcbd731e2c307acd6a/pyflakes-2.4.0.tar.gz" + } + ], + "project_name": "pyflakes", + "requires_dists": [], + "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7", + "version": "2.4" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "f62ea9da9ed6289bfe868cd6845968a2c854d1427f8548d52cae02a42b4f0356", + "url": "https://files.pythonhosted.org/packages/41/82/7f54bbfe5c247a8c9f78d8d1d7c051847bcb78843c397b866dba335c1e88/setuptools-65.5.0-py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "512e5536220e38146176efb833d4a62aa726b7bbff82cfbc8ba9eaa3996e0b17", + "url": "https://files.pythonhosted.org/packages/c5/41/247814d8b7a044717164c74080725a6c8f3d2b5fc82b34bd825b617df663/setuptools-65.5.0.tar.gz" + } + ], + "project_name": "setuptools", + "requires_dists": [ + "build[virtualenv]; extra == \"testing\"", + "build[virtualenv]; extra == \"testing-integration\"", + "filelock>=3.4.0; extra == \"testing\"", + "filelock>=3.4.0; extra == \"testing-integration\"", + "flake8-2020; extra == \"testing\"", + "flake8<5; extra == \"testing\"", + "furo; extra == \"docs\"", + "ini2toml[lite]>=0.9; extra == \"testing\"", + "jaraco.envs>=2.2; extra == \"testing\"", + "jaraco.envs>=2.2; extra == \"testing-integration\"", + "jaraco.packaging>=9; extra == \"docs\"", + "jaraco.path>=3.2.0; extra == \"testing\"", + "jaraco.path>=3.2.0; extra == \"testing-integration\"", + "jaraco.tidelift>=1.4; extra == \"docs\"", + "mock; extra == \"testing\"", + "pip-run>=8.8; extra == \"testing\"", + "pip>=19.1; extra == \"testing\"", + "pygments-github-lexers==0.0.5; extra == \"docs\"", + "pytest-black>=0.3.7; platform_python_implementation != \"PyPy\" and extra == \"testing\"", + "pytest-checkdocs>=2.4; extra == \"testing\"", + "pytest-cov; platform_python_implementation != \"PyPy\" and extra == \"testing\"", + "pytest-enabler; extra == \"testing-integration\"", + "pytest-enabler>=1.3; extra == \"testing\"", + "pytest-flake8; extra == \"testing\"", + "pytest-mypy>=0.9.1; platform_python_implementation != \"PyPy\" and extra == \"testing\"", + "pytest-perf; extra == \"testing\"", + "pytest-xdist; extra == \"testing\"", + "pytest-xdist; extra == \"testing-integration\"", + "pytest; extra == \"testing-integration\"", + "pytest>=6; extra == \"testing\"", + "rst.linker>=1.9; extra == \"docs\"", + "sphinx-favicon; extra == \"docs\"", + "sphinx-hoverxref<2; extra == \"docs\"", + "sphinx-inline-tabs; extra == \"docs\"", + "sphinx-notfound-page==0.8.3; extra == \"docs\"", + "sphinx-reredirects; extra == \"docs\"", + "sphinx>=3.5; extra == \"docs\"", + "sphinxcontrib-towncrier; extra == \"docs\"", + "tomli-w>=1.0.0; extra == \"testing\"", + "tomli; extra == \"testing-integration\"", + "virtualenv>=13.0.0; extra == \"testing\"", + "virtualenv>=13.0.0; extra == \"testing-integration\"", + "wheel; extra == \"testing\"", + "wheel; extra == \"testing-integration\"" + ], + "requires_python": ">=3.7", + "version": "65.5" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "8e163d489ca8d20a43ccd428acbefdfd451fb38d624d140e6711d510530db01a", + "url": "https://files.pythonhosted.org/packages/81/4c/8ece3543c6153bbf1883629e5fe7270b43aebf0bd7c85c552aedc0555b13/st2flake8-0.1.0-py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "4808e5ba811b792eec8a255988a3d1d3e615768dbc89d043774cf821d4584a8f", + "url": "https://files.pythonhosted.org/packages/64/c7/9b6dd9ba15a44a6fd9aa733beb4a2ca9d9234bf57b8a828d4b6c127fe427/st2flake8-0.1.0.tar.gz" + } + ], + "project_name": "st2flake8", + "requires_dists": [ + "flake8-copyright==0.2.2", + "flake8-polyfill==1.0.2" + ], + "requires_python": null, + "version": "0.1" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e", + "url": "https://files.pythonhosted.org/packages/0b/8e/f1a0a5a76cfef77e1eb6004cb49e5f8d72634da638420b9ea492ce8305e8/typing_extensions-4.4.0-py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa", + "url": "https://files.pythonhosted.org/packages/e3/a7/8f4e456ef0adac43f452efc2d0e4b242ab831297f1bac60ac815d37eb9cf/typing_extensions-4.4.0.tar.gz" + } + ], + "project_name": "typing-extensions", + "requires_dists": [], + "requires_python": ">=3.7", + "version": "4.4" + }, + { + "artifacts": [ + { + "algorithm": "sha256", + "hash": "972cfa31bc2fedd3fa838a51e9bc7e64b7fb725a8c00e7431554311f180e9980", + "url": "https://files.pythonhosted.org/packages/09/85/302c153615db93e9197f13e02f448b3f95d7d786948f2fb3d6d5830a481b/zipp-3.9.0-py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "3a7af91c3db40ec72dd9d154ae18e008c69efe8ca88dde4f9a731bb82fe2f9eb", + "url": "https://files.pythonhosted.org/packages/41/2e/1341c5634c25e7254df01ec1f6cbd2bcdee3e647709e7c3647d1b362e3ac/zipp-3.9.0.tar.gz" + } + ], + "project_name": "zipp", + "requires_dists": [ + "flake8<5; extra == \"testing\"", + "func-timeout; extra == \"testing\"", + "furo; extra == \"docs\"", + "jaraco.functools; extra == \"testing\"", + "jaraco.itertools; extra == \"testing\"", + "jaraco.packaging>=9; extra == \"docs\"", + "jaraco.tidelift>=1.4; extra == \"docs\"", + "more-itertools; extra == \"testing\"", + "pytest-black>=0.3.7; platform_python_implementation != \"PyPy\" and extra == \"testing\"", + "pytest-checkdocs>=2.4; extra == \"testing\"", + "pytest-cov; extra == \"testing\"", + "pytest-enabler>=1.3; extra == \"testing\"", + "pytest-flake8; extra == \"testing\"", + "pytest-mypy>=0.9.1; platform_python_implementation != \"PyPy\" and extra == \"testing\"", + "pytest>=6; extra == \"testing\"", + "rst.linker>=1.9; extra == \"docs\"", + "sphinx>=3.5; extra == \"docs\"" + ], + "requires_python": ">=3.7", + "version": "3.9" + } + ], + "platform_tag": null + } + ], + "path_mappings": {}, + "pex_version": "2.1.103", + "prefer_older_binary": false, + "requirements": [ + "flake8==4.0.1", + "st2flake8==0.1.0" + ], + "requires_python": [ + "<4,>=3.7" + ], + "resolver_version": "pip-2020-resolver", + "style": "universal", + "target_systems": [ + "linux", + "mac" + ], + "transitive": true, + "use_pep517": null +} diff --git a/pants.toml b/pants.toml index 92a138a375..18c350d14e 100644 --- a/pants.toml +++ b/pants.toml @@ -13,6 +13,7 @@ backend_packages = [ "pants.backend.experimental.python", # activates twine `publish` support "pants.backend.python.mixed_interpreter_constraints", "pants.backend.python.lint.black", + "pants.backend.python.lint.flake8", # shell "pants.backend.shell", @@ -85,3 +86,12 @@ root_patterns = [ [black] lockfile = "lockfiles/black.lock" version = "black==22.3.0" + +[flake8] +lockfile = "lockfiles/flake8.lock" +version = "flake8==4.0.1" # st2flake8 does not support flake8 v5 +extra_requirements = [ + # license check plugin + "st2flake8==0.1.0", # TODO: remove in favor of regex-lint +] +config = "lint-configs/python/.flake8" diff --git a/st2actions/bin/BUILD b/st2actions/bin/BUILD index 73f2312907..0849f21f07 100644 --- a/st2actions/bin/BUILD +++ b/st2actions/bin/BUILD @@ -1,5 +1,6 @@ python_sources( sources=["st2*"], + skip_flake8=True, ) shell_sources( diff --git a/st2api/bin/BUILD b/st2api/bin/BUILD index 05411bee10..4b7a4f7f9e 100644 --- a/st2api/bin/BUILD +++ b/st2api/bin/BUILD @@ -1,3 +1,4 @@ python_sources( sources=["st2*"], + skip_flake8=True, ) diff --git a/st2auth/bin/BUILD b/st2auth/bin/BUILD index 05411bee10..4b7a4f7f9e 100644 --- a/st2auth/bin/BUILD +++ b/st2auth/bin/BUILD @@ -1,3 +1,4 @@ python_sources( sources=["st2*"], + skip_flake8=True, ) diff --git a/st2common/bin/BUILD b/st2common/bin/BUILD index f579a5aadc..84559dd837 100644 --- a/st2common/bin/BUILD +++ b/st2common/bin/BUILD @@ -1,5 +1,6 @@ python_sources( sources=["*.py", "st2*", "!st2ctl", "!st2-self-check", "!st2-run-pack-tests"], + skip_flake8=True, ) shell_sources( diff --git a/st2reactor/bin/BUILD b/st2reactor/bin/BUILD index 05411bee10..4b7a4f7f9e 100644 --- a/st2reactor/bin/BUILD +++ b/st2reactor/bin/BUILD @@ -1,3 +1,4 @@ python_sources( sources=["st2*"], + skip_flake8=True, ) diff --git a/st2stream/bin/BUILD b/st2stream/bin/BUILD index 05411bee10..4b7a4f7f9e 100644 --- a/st2stream/bin/BUILD +++ b/st2stream/bin/BUILD @@ -1,3 +1,4 @@ python_sources( sources=["st2*"], + skip_flake8=True, )