From dd528f6f51e79899eff22fea9c0a8b82a9ac5d2f Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Sat, 3 Aug 2024 13:51:34 +0200 Subject: [PATCH] Replaced flake with ruff. Signed-off-by: Pavel Kirilin --- .flake8 | 137 ------- .github/workflows/release.yml | 2 + .github/workflows/test.yml | 51 +-- .pre-commit-config.yaml | 30 +- poetry.lock | 590 ++------------------------- pyproject.toml | 79 +++- taskiq_pipelines/abc.py | 7 +- taskiq_pipelines/exceptions.py | 2 +- taskiq_pipelines/middleware.py | 2 +- taskiq_pipelines/pipeliner.py | 8 +- taskiq_pipelines/steps/__init__.py | 2 +- taskiq_pipelines/steps/filter.py | 39 +- taskiq_pipelines/steps/mapper.py | 13 +- taskiq_pipelines/steps/sequential.py | 7 +- 14 files changed, 157 insertions(+), 812 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 5f4f08f..0000000 --- a/.flake8 +++ /dev/null @@ -1,137 +0,0 @@ -[flake8] -max-complexity = 6 -inline-quotes = double -max-line-length = 88 -extend-ignore = E203 -docstring_style=sphinx -max-cognitive-score=20 -max-arguments=8 -max-line-complexity=20 - -ignore = - ; Found statement that has no effect - WPS428, - ; Found overly complex annotation - WPS234, - ; Found multi-line function type annotation - WPS320, - ; Found too deep nesting - WPS220, - ; Found `%` string formatting - WPS323, - ; Found `f` string - WPS305, - ; Missing docstring in public module - D100, - ; Missing docstring in magic method - D105, - ; Missing docstring in __init__ - D107, - ; Found `__init__.py` module with logic - WPS412, - ; Found class without a base class - WPS306, - ; Missing docstring in public nested class - D106, - ; First line should be in imperative mood - D401, - ; Found wrong variable name - WPS110, - ; Found `__init__.py` module with logic - WPS326, - ; Found string constant over-use - WPS226, - ; Found upper-case constant in a class - WPS115, - ; Found nested function - WPS602, - ; Found method without arguments - WPS605, - ; Found overused expression - WPS204, - ; Found too many module members - WPS202, - ; Found too high module cognitive complexity - WPS232, - ; line break before binary operator - W503, - ; Found module with too many imports - WPS201, - ; Inline strong start-string without end-string. - RST210, - ; Found nested class - WPS431, - ; Found wrong module name - WPS100, - ; Found too many methods - WPS214, - ; Found too long ``try`` body - WPS229, - ; Found unpythonic getter or setter - WPS615, - ; Found a line that starts with a dot - WPS348, - ; Found complex default value (for dependency injection) - WPS404, - ; not perform function calls in argument defaults (for dependency injection) - B008, - ; Model should define verbose_name in its Meta inner class - DJ10, - ; Model should define verbose_name_plural in its Meta inner class - DJ11, - ; Found mutable module constant. - WPS407, - ; Found walrus operator - WPS332 - ; Found a too complex `f` string - WPS237 - ; Consider possible security implications associated with pickle module - ; Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue - S403, S301 - ; Found too many imported names from a module - WPS235 - -per-file-ignores = - ; all tests - test_*.py,tests.py,tests_*.py,*/tests/*,conftest.py: - ; Use of assert detected - S101, - ; Found outer scope names shadowing - WPS442, - ; Found too many local variables - WPS210, - ; Found magic number - WPS432, - ; Missing parameter(s) in Docstring - DAR101, - ; Found too many arguments - WPS211, - ; Found nested function - WPS430, - ; Found too short name - WPS111, - - ; all init files - __init__.py: - ; ignore not used imports - F401, - ; ignore import with wildcard - F403, - ; Found wrong metadata variable - WPS410, - -exclude = - ./.cache, - ./.git, - ./.idea, - ./.mypy_cache, - ./.pytest_cache, - ./.venv, - ./venv, - ./env, - ./cached_venv, - ./docs, - ./deploy, - ./var, - ./.vscode, - *migrations*, diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 335b46d..d9dd65c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,8 @@ jobs: uses: knowsuchagency/poetry-install@v1 env: POETRY_VIRTUALENVS_CREATE: false + - name: Set verison + run: poetry version "${{ github.ref_name }}" - name: Release package env: POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fcf63e3..926783f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,48 +3,27 @@ name: Testing taskiq-pipelines on: pull_request jobs: - black: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.9" - - name: Install deps - uses: knowsuchagency/poetry-install@v1 - env: - POETRY_VIRTUALENVS_CREATE: false - - name: Run black check - run: poetry run black --check . - flake8: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.9" - - name: Install deps - uses: knowsuchagency/poetry-install@v1 - env: - POETRY_VIRTUALENVS_CREATE: false - - name: Run flake8 check - run: poetry run flake8 --count . - mypy: + lint: + strategy: + matrix: + cmd: + - black + - ruff + - mypy runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Install poetry + run: pipx install poetry - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: "3.9" + python-version: "3.11" + cache: "poetry" - name: Install deps - uses: knowsuchagency/poetry-install@v1 - env: - POETRY_VIRTUALENVS_CREATE: false - - name: Run mypy check - run: poetry run mypy . + run: poetry install --all-extras + - name: Run lint check + run: poetry run pre-commit run -a ${{ matrix.cmd }} pytest: strategy: matrix: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7201333..4f2cdc1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,35 +22,19 @@ repos: language: system types: [python] - - id: autoflake - name: autoflake - entry: poetry run autoflake - language: system - types: [python] - args: [--in-place, --remove-all-unused-imports, --remove-duplicate-keys] - - - id: isort - name: isort - entry: poetry run isort - language: system - types: [python] - - - id: flake8 - name: Check with Flake8 - entry: poetry run flake8 + - id: ruff + name: Run ruff lints + entry: poetry run ruff language: system pass_filenames: false types: [python] - args: [--count, taskiq_pipelines, tests] + args: + - "check" + - "--fix" + - "." - id: mypy name: Validate types with MyPy entry: poetry run mypy language: system types: [python] - - - id: yesqa - name: Remove usless noqa - entry: poetry run yesqa - language: system - types: [python] diff --git a/poetry.lock b/poetry.lock index 3fd3136..a04485f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -35,75 +35,6 @@ doc = ["Sphinx", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd- test = ["anyio[trio]", "coverage[toml] (>=4.5)", "hypothesis (>=4.0)", "mock (>=4)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"] trio = ["trio (<0.22)"] -[[package]] -name = "astor" -version = "0.8.1" -description = "Read/rewrite/write Python ASTs" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" -files = [ - {file = "astor-0.8.1-py2.py3-none-any.whl", hash = "sha256:070a54e890cefb5b3739d19f30f5a5ec840ffc9c50ffa7d23cc9fc1a38ebbfc5"}, - {file = "astor-0.8.1.tar.gz", hash = "sha256:6a6effda93f4e1ce9f618779b2dd1d9d84f1e32812c23a29b3fff6fd7f63fa5e"}, -] - -[[package]] -name = "attrs" -version = "23.2.0" -description = "Classes Without Boilerplate" -optional = false -python-versions = ">=3.7" -files = [ - {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, - {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, -] - -[package.extras] -cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] -dev = ["attrs[tests]", "pre-commit"] -docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope-interface"] -tests = ["attrs[tests-no-zope]", "zope-interface"] -tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"] -tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"] - -[[package]] -name = "autoflake" -version = "1.7.7" -description = "Removes unused imports and unused variables" -optional = false -python-versions = ">=3.7" -files = [ - {file = "autoflake-1.7.7-py3-none-any.whl", hash = "sha256:a9b43d08f8e455824e4f7b3f078399f59ba538ba53872f466c09e55c827773ef"}, - {file = "autoflake-1.7.7.tar.gz", hash = "sha256:c8e4fc41aa3eae0f5c94b939e3a3d50923d7a9306786a6cbf4866a077b8f6832"}, -] - -[package.dependencies] -pyflakes = ">=1.1.0" -tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""} - -[[package]] -name = "bandit" -version = "1.7.9" -description = "Security oriented static analyser for python code." -optional = false -python-versions = ">=3.8" -files = [ - {file = "bandit-1.7.9-py3-none-any.whl", hash = "sha256:52077cb339000f337fb25f7e045995c4ad01511e716e5daac37014b9752de8ec"}, - {file = "bandit-1.7.9.tar.gz", hash = "sha256:7c395a436743018f7be0a4cbb0a4ea9b902b6d87264ddecf8cfdc73b4f78ff61"}, -] - -[package.dependencies] -colorama = {version = ">=0.3.9", markers = "platform_system == \"Windows\""} -PyYAML = ">=5.3.1" -rich = "*" -stevedore = ">=1.20.0" - -[package.extras] -baseline = ["GitPython (>=3.1.30)"] -sarif = ["jschema-to-python (>=1.2.3)", "sarif-om (>=1.0.4)"] -test = ["beautifulsoup4 (>=4.8.0)", "coverage (>=4.5.4)", "fixtures (>=3.0.0)", "flake8 (>=4.0.0)", "pylint (==1.9.4)", "stestr (>=2.5.0)", "testscenarios (>=0.5.0)", "testtools (>=2.3.0)"] -toml = ["tomli (>=1.1.0)"] -yaml = ["PyYAML"] - [[package]] name = "black" version = "22.12.0" @@ -242,17 +173,6 @@ tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.1 [package.extras] toml = ["tomli"] -[[package]] -name = "darglint" -version = "1.8.1" -description = "A utility for ensuring Google-style docstrings stay up to date with the source code." -optional = false -python-versions = ">=3.6,<4.0" -files = [ - {file = "darglint-1.8.1-py3-none-any.whl", hash = "sha256:5ae11c259c17b0701618a20c3da343a3eb98b3bc4b5a83d31cdd94f5ebdced8d"}, - {file = "darglint-1.8.1.tar.gz", hash = "sha256:080d5106df149b199822e7ee7deb9c012b49891538f14a11be681044f0bb20da"}, -] - [[package]] name = "distlib" version = "0.3.8" @@ -264,25 +184,6 @@ files = [ {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, ] -[[package]] -name = "docutils" -version = "0.20.1" -description = "Docutils -- Python Documentation Utilities" -optional = false -python-versions = "*" -files = [] - -[[package]] -name = "eradicate" -version = "2.3.0" -description = "Removes commented-out code." -optional = false -python-versions = "*" -files = [ - {file = "eradicate-2.3.0-py3-none-any.whl", hash = "sha256:2b29b3dd27171f209e4ddd8204b70c02f0682ae95eecb353f10e8d72b149c63e"}, - {file = "eradicate-2.3.0.tar.gz", hash = "sha256:06df115be3b87d0fc1c483db22a2ebb12bcf40585722810d809cc770f5031c37"}, -] - [[package]] name = "exceptiongroup" version = "1.2.2" @@ -327,208 +228,6 @@ docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1 testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-asyncio (>=0.21)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)", "virtualenv (>=20.26.2)"] typing = ["typing-extensions (>=4.8)"] -[[package]] -name = "flake8" -version = "6.1.0" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-6.1.0-py2.py3-none-any.whl", hash = "sha256:ffdfce58ea94c6580c77888a86506937f9a1a227dfcd15f245d694ae20a6b6e5"}, - {file = "flake8-6.1.0.tar.gz", hash = "sha256:d5b3857f07c030bdb5bf41c7f53799571d75c4491748a3adcd47de929e34cd23"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.11.0,<2.12.0" -pyflakes = ">=3.1.0,<3.2.0" - -[[package]] -name = "flake8-bandit" -version = "4.1.1" -description = "Automated security testing with bandit and flake8." -optional = false -python-versions = ">=3.6" -files = [ - {file = "flake8_bandit-4.1.1-py3-none-any.whl", hash = "sha256:4c8a53eb48f23d4ef1e59293657181a3c989d0077c9952717e98a0eace43e06d"}, - {file = "flake8_bandit-4.1.1.tar.gz", hash = "sha256:068e09287189cbfd7f986e92605adea2067630b75380c6b5733dab7d87f9a84e"}, -] - -[package.dependencies] -bandit = ">=1.7.3" -flake8 = ">=5.0.0" - -[[package]] -name = "flake8-broken-line" -version = "1.0.0" -description = "Flake8 plugin to forbid backslashes for line breaks" -optional = false -python-versions = ">=3.8,<4.0" -files = [ - {file = "flake8_broken_line-1.0.0-py3-none-any.whl", hash = "sha256:96c964336024a5030dc536a9f6fb02aa679e2d2a6b35b80a558b5136c35832a9"}, - {file = "flake8_broken_line-1.0.0.tar.gz", hash = "sha256:e2c6a17f8d9a129e99c1320fce89b33843e2963871025c4c2bb7b8b8d8732a85"}, -] - -[package.dependencies] -flake8 = ">5" - -[[package]] -name = "flake8-bugbear" -version = "23.12.2" -description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle." -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-bugbear-23.12.2.tar.gz", hash = "sha256:32b2903e22331ae04885dae25756a32a8c666c85142e933f43512a70f342052a"}, - {file = "flake8_bugbear-23.12.2-py3-none-any.whl", hash = "sha256:83324bad4d90fee4bf64dd69c61aff94debf8073fbd807c8b6a36eec7a2f0719"}, -] - -[package.dependencies] -attrs = ">=19.2.0" -flake8 = ">=6.0.0" - -[package.extras] -dev = ["coverage", "hypothesis", "hypothesmith (>=0.2)", "pre-commit", "pytest", "tox"] - -[[package]] -name = "flake8-commas" -version = "2.1.0" -description = "Flake8 lint for trailing commas." -optional = false -python-versions = "*" -files = [ - {file = "flake8-commas-2.1.0.tar.gz", hash = "sha256:940441ab8ee544df564ae3b3f49f20462d75d5c7cac2463e0b27436e2050f263"}, - {file = "flake8_commas-2.1.0-py2.py3-none-any.whl", hash = "sha256:ebb96c31e01d0ef1d0685a21f3f0e2f8153a0381430e748bf0bbbb5d5b453d54"}, -] - -[package.dependencies] -flake8 = ">=2" - -[[package]] -name = "flake8-comprehensions" -version = "3.15.0" -description = "A flake8 plugin to help you write better list/set/dict comprehensions." -optional = false -python-versions = ">=3.8" -files = [ - {file = "flake8_comprehensions-3.15.0-py3-none-any.whl", hash = "sha256:b7e027bbb52be2ceb779ee12484cdeef52b0ad3c1fcb8846292bdb86d3034681"}, - {file = "flake8_comprehensions-3.15.0.tar.gz", hash = "sha256:923c22603e0310376a6b55b03efebdc09753c69f2d977755cba8bb73458a5d4d"}, -] - -[package.dependencies] -flake8 = ">=3,<3.2 || >3.2" - -[[package]] -name = "flake8-debugger" -version = "4.1.2" -description = "ipdb/pdb statement checker plugin for flake8" -optional = false -python-versions = ">=3.7" -files = [ - {file = "flake8-debugger-4.1.2.tar.gz", hash = "sha256:52b002560941e36d9bf806fca2523dc7fb8560a295d5f1a6e15ac2ded7a73840"}, - {file = "flake8_debugger-4.1.2-py3-none-any.whl", hash = "sha256:0a5e55aeddcc81da631ad9c8c366e7318998f83ff00985a49e6b3ecf61e571bf"}, -] - -[package.dependencies] -flake8 = ">=3.0" -pycodestyle = "*" - -[[package]] -name = "flake8-docstrings" -version = "1.7.0" -description = "Extension for flake8 which uses pydocstyle to check docstrings" -optional = false -python-versions = ">=3.7" -files = [ - {file = "flake8_docstrings-1.7.0-py2.py3-none-any.whl", hash = "sha256:51f2344026da083fc084166a9353f5082b01f72901df422f74b4d953ae88ac75"}, - {file = "flake8_docstrings-1.7.0.tar.gz", hash = "sha256:4c8cc748dc16e6869728699e5d0d685da9a10b0ea718e090b1ba088e67a941af"}, -] - -[package.dependencies] -flake8 = ">=3" -pydocstyle = ">=2.1" - -[[package]] -name = "flake8-eradicate" -version = "1.5.0" -description = "Flake8 plugin to find commented out code" -optional = false -python-versions = ">=3.8,<4.0" -files = [ - {file = "flake8_eradicate-1.5.0-py3-none-any.whl", hash = "sha256:18acc922ad7de623f5247c7d5595da068525ec5437dd53b22ec2259b96ce9d22"}, - {file = "flake8_eradicate-1.5.0.tar.gz", hash = "sha256:aee636cb9ecb5594a7cd92d67ad73eb69909e5cc7bd81710cf9d00970f3983a6"}, -] - -[package.dependencies] -attrs = "*" -eradicate = ">=2.0,<3.0" -flake8 = ">5" - -[[package]] -name = "flake8-isort" -version = "6.1.1" -description = "flake8 plugin that integrates isort" -optional = false -python-versions = ">=3.8" -files = [ - {file = "flake8_isort-6.1.1-py3-none-any.whl", hash = "sha256:0fec4dc3a15aefbdbe4012e51d5531a2eb5fa8b981cdfbc882296a59b54ede12"}, - {file = "flake8_isort-6.1.1.tar.gz", hash = "sha256:c1f82f3cf06a80c13e1d09bfae460e9666255d5c780b859f19f8318d420370b3"}, -] - -[package.dependencies] -flake8 = "*" -isort = ">=5.0.0,<6" - -[package.extras] -test = ["pytest"] - -[[package]] -name = "flake8-quotes" -version = "3.4.0" -description = "Flake8 lint for quotes." -optional = false -python-versions = "*" -files = [ - {file = "flake8-quotes-3.4.0.tar.gz", hash = "sha256:aad8492fb710a2d3eabe68c5f86a1428de650c8484127e14c43d0504ba30276c"}, -] - -[package.dependencies] -flake8 = "*" -setuptools = "*" - -[[package]] -name = "flake8-rst-docstrings" -version = "0.3.0" -description = "Python docstring reStructuredText (RST) validator for flake8" -optional = false -python-versions = ">=3.7" -files = [ - {file = "flake8-rst-docstrings-0.3.0.tar.gz", hash = "sha256:d1ce22b4bd37b73cd86b8d980e946ef198cfcc18ed82fedb674ceaa2f8d1afa4"}, - {file = "flake8_rst_docstrings-0.3.0-py3-none-any.whl", hash = "sha256:f8c3c6892ff402292651c31983a38da082480ad3ba253743de52989bdc84ca1c"}, -] - -[package.dependencies] -flake8 = ">=3" -pygments = "*" -restructuredtext-lint = "*" - -[package.extras] -develop = ["build", "twine"] - -[[package]] -name = "flake8-string-format" -version = "0.3.0" -description = "string format checker, plugin for flake8" -optional = false -python-versions = "*" -files = [ - {file = "flake8-string-format-0.3.0.tar.gz", hash = "sha256:65f3da786a1461ef77fca3780b314edb2853c377f2e35069723348c8917deaa2"}, - {file = "flake8_string_format-0.3.0-py2.py3-none-any.whl", hash = "sha256:812ff431f10576a74c89be4e85b8e075a705be39bc40c4b4278b5b13e2afa9af"}, -] - -[package.dependencies] -flake8 = "*" - [[package]] name = "graphlib-backport" version = "1.1.0" @@ -595,66 +294,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "isort" -version = "5.13.2" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, - {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, -] - -[package.extras] -colors = ["colorama (>=0.4.6)"] - -[[package]] -name = "markdown-it-py" -version = "3.0.0" -description = "Python port of markdown-it. Markdown parsing, done right!" -optional = false -python-versions = ">=3.8" -files = [ - {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, - {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"}, -] - -[package.dependencies] -mdurl = ">=0.1,<1.0" - -[package.extras] -benchmarking = ["psutil", "pytest", "pytest-benchmark"] -code-style = ["pre-commit (>=3.0,<4.0)"] -compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"] -linkify = ["linkify-it-py (>=1,<3)"] -plugins = ["mdit-py-plugins"] -profiling = ["gprof2dot"] -rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] -testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] - -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - -[[package]] -name = "mdurl" -version = "0.1.2" -description = "Markdown URL utilities" -optional = false -python-versions = ">=3.7" -files = [ - {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, - {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, -] - [[package]] name = "mypy" version = "1.11.1" @@ -746,31 +385,6 @@ files = [ {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, ] -[[package]] -name = "pbr" -version = "6.0.0" -description = "Python Build Reasonableness" -optional = false -python-versions = ">=2.6" -files = [ - {file = "pbr-6.0.0-py2.py3-none-any.whl", hash = "sha256:4a7317d5e3b17a3dccb6a8cfe67dab65b20551404c52c8ed41279fa4f0cb4cda"}, - {file = "pbr-6.0.0.tar.gz", hash = "sha256:d1377122a5a00e2f940ee482999518efe16d745d423a670c27773dfbc3c9a7d9"}, -] - -[[package]] -name = "pep8-naming" -version = "0.13.3" -description = "Check PEP-8 naming conventions, plugin for flake8" -optional = false -python-versions = ">=3.7" -files = [ - {file = "pep8-naming-0.13.3.tar.gz", hash = "sha256:1705f046dfcd851378aac3be1cd1551c7c1e5ff363bacad707d43007877fa971"}, - {file = "pep8_naming-0.13.3-py3-none-any.whl", hash = "sha256:1a86b8c71a03337c97181917e2b472f0f5e4ccb06844a0d6f0a33522549e7a80"}, -] - -[package.dependencies] -flake8 = ">=5.0.0" - [[package]] name = "platformdirs" version = "4.2.2" @@ -860,17 +474,6 @@ files = [ {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] -[[package]] -name = "pycodestyle" -version = "2.11.1" -description = "Python style guide checker" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, - {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, -] - [[package]] name = "pycron" version = "3.0.0" @@ -1004,48 +607,6 @@ files = [ [package.dependencies] typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" -[[package]] -name = "pydocstyle" -version = "6.3.0" -description = "Python docstring style checker" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pydocstyle-6.3.0-py3-none-any.whl", hash = "sha256:118762d452a49d6b05e194ef344a55822987a462831ade91ec5c06fd2169d019"}, - {file = "pydocstyle-6.3.0.tar.gz", hash = "sha256:7ce43f0c0ac87b07494eb9c0b462c0b73e6ff276807f204d6b53edc72b7e44e1"}, -] - -[package.dependencies] -snowballstemmer = ">=2.2.0" - -[package.extras] -toml = ["tomli (>=1.2.3)"] - -[[package]] -name = "pyflakes" -version = "3.1.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pyflakes-3.1.0-py2.py3-none-any.whl", hash = "sha256:4132f6d49cb4dae6819e5379898f2b8cce3c5f23994194c24b77d5da2e36f774"}, - {file = "pyflakes-3.1.0.tar.gz", hash = "sha256:a0aae034c444db0071aa077972ba4768d40c830d9539fd45bf4cd3f8f6992efc"}, -] - -[[package]] -name = "pygments" -version = "2.18.0" -description = "Pygments is a syntax highlighting package written in Python." -optional = false -python-versions = ">=3.8" -files = [ - {file = "pygments-2.18.0-py3-none-any.whl", hash = "sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a"}, - {file = "pygments-2.18.0.tar.gz", hash = "sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199"}, -] - -[package.extras] -windows-terminal = ["colorama (>=0.4.6)"] - [[package]] name = "pytest" version = "7.4.4" @@ -1195,53 +756,32 @@ files = [ ] [[package]] -name = "restructuredtext-lint" -version = "1.4.0" -description = "reStructuredText linter" -optional = false -python-versions = "*" -files = [ - {file = "restructuredtext_lint-1.4.0.tar.gz", hash = "sha256:1b235c0c922341ab6c530390892eb9e92f90b9b75046063e047cacfb0f050c45"}, -] - -[package.dependencies] -docutils = ">=0.11,<1.0" - -[[package]] -name = "rich" -version = "13.7.1" -description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" -optional = false -python-versions = ">=3.7.0" -files = [ - {file = "rich-13.7.1-py3-none-any.whl", hash = "sha256:4edbae314f59eb482f54e9e30bf00d33350aaa94f4bfcd4e9e3110e64d0d7222"}, - {file = "rich-13.7.1.tar.gz", hash = "sha256:9be308cb1fe2f1f57d67ce99e95af38a1e2bc71ad9813b0e247cf7ffbcc3a432"}, -] - -[package.dependencies] -markdown-it-py = ">=2.2.0" -pygments = ">=2.13.0,<3.0.0" -typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9\""} - -[package.extras] -jupyter = ["ipywidgets (>=7.5.1,<9)"] - -[[package]] -name = "setuptools" -version = "72.1.0" -description = "Easily download, build, install, upgrade, and uninstall Python packages" +name = "ruff" +version = "0.5.6" +description = "An extremely fast Python linter and code formatter, written in Rust." optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "setuptools-72.1.0-py3-none-any.whl", hash = "sha256:5a03e1860cf56bb6ef48ce186b0e557fdba433237481a9a625176c2831be15d1"}, - {file = "setuptools-72.1.0.tar.gz", hash = "sha256:8d243eff56d095e5817f796ede6ae32941278f542e0f941867cc05ae52b162ec"}, + {file = "ruff-0.5.6-py3-none-linux_armv6l.whl", hash = "sha256:a0ef5930799a05522985b9cec8290b185952f3fcd86c1772c3bdbd732667fdcd"}, + {file = "ruff-0.5.6-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b652dc14f6ef5d1552821e006f747802cc32d98d5509349e168f6bf0ee9f8f42"}, + {file = "ruff-0.5.6-py3-none-macosx_11_0_arm64.whl", hash = "sha256:80521b88d26a45e871f31e4b88938fd87db7011bb961d8afd2664982dfc3641a"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d9bc8f328a9f1309ae80e4d392836e7dbc77303b38ed4a7112699e63d3b066ab"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4d394940f61f7720ad371ddedf14722ee1d6250fd8d020f5ea5a86e7be217daf"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:111a99cdb02f69ddb2571e2756e017a1496c2c3a2aeefe7b988ddab38b416d36"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:e395daba77a79f6dc0d07311f94cc0560375ca20c06f354c7c99af3bf4560c5d"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c476acb43c3c51e3c614a2e878ee1589655fa02dab19fe2db0423a06d6a5b1b6"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e2ff8003f5252fd68425fd53d27c1f08b201d7ed714bb31a55c9ac1d4c13e2eb"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c94e084ba3eaa80c2172918c2ca2eb2230c3f15925f4ed8b6297260c6ef179ad"}, + {file = "ruff-0.5.6-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1f77c1c3aa0669fb230b06fb24ffa3e879391a3ba3f15e3d633a752da5a3e670"}, + {file = "ruff-0.5.6-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:f908148c93c02873210a52cad75a6eda856b2cbb72250370ce3afef6fb99b1ed"}, + {file = "ruff-0.5.6-py3-none-musllinux_1_2_i686.whl", hash = "sha256:563a7ae61ad284187d3071d9041c08019975693ff655438d8d4be26e492760bd"}, + {file = "ruff-0.5.6-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:94fe60869bfbf0521e04fd62b74cbca21cbc5beb67cbb75ab33fe8c174f54414"}, + {file = "ruff-0.5.6-py3-none-win32.whl", hash = "sha256:e6a584c1de6f8591c2570e171cc7ce482bb983d49c70ddf014393cd39e9dfaed"}, + {file = "ruff-0.5.6-py3-none-win_amd64.whl", hash = "sha256:d7fe7dccb1a89dc66785d7aa0ac283b2269712d8ed19c63af908fdccca5ccc1a"}, + {file = "ruff-0.5.6-py3-none-win_arm64.whl", hash = "sha256:57c6c0dd997b31b536bff49b9eee5ed3194d60605a4427f735eeb1f9c1b8d264"}, + {file = "ruff-0.5.6.tar.gz", hash = "sha256:07c9e3c2a8e1fe377dd460371c3462671a728c981c3205a5217291422209f642"}, ] -[package.extras] -core = ["importlib-metadata (>=6)", "importlib-resources (>=5.10.2)", "jaraco.text (>=3.7)", "more-itertools (>=8.8)", "ordered-set (>=3.1.1)", "packaging (>=24)", "platformdirs (>=2.6.2)", "tomli (>=2.0.1)", "wheel (>=0.43.0)"] -doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "pyproject-hooks (!=1.1)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "jaraco.test", "mypy (==1.11.*)", "packaging (>=23.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy", "pytest-perf", "pytest-ruff (<0.4)", "pytest-ruff (>=0.2.1)", "pytest-ruff (>=0.3.2)", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] - [[package]] name = "sniffio" version = "1.3.1" @@ -1253,31 +793,6 @@ files = [ {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, ] -[[package]] -name = "snowballstemmer" -version = "2.2.0" -description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." -optional = false -python-versions = "*" -files = [ - {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, - {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, -] - -[[package]] -name = "stevedore" -version = "5.2.0" -description = "Manage dynamic plugins for Python applications" -optional = false -python-versions = ">=3.8" -files = [ - {file = "stevedore-5.2.0-py3-none-any.whl", hash = "sha256:1c15d95766ca0569cad14cb6272d4d31dae66b011a929d7c18219c176ea1b5c9"}, - {file = "stevedore-5.2.0.tar.gz", hash = "sha256:46b93ca40e1114cea93d738a6c1e365396981bb6bb78c27045b7587c9473544d"}, -] - -[package.dependencies] -pbr = ">=2.0.0,<2.1.0 || >2.1.0" - [[package]] name = "taskiq" version = "0.11.6" @@ -1323,17 +838,6 @@ files = [ graphlib-backport = {version = ">=1.0.3,<2.0.0", markers = "python_version < \"3.9\""} typing-extensions = {version = ">=4.6.3,<5.0.0", markers = "python_version < \"3.10\""} -[[package]] -name = "tokenize-rt" -version = "5.2.0" -description = "A wrapper around the stdlib `tokenize` which roundtrips." -optional = false -python-versions = ">=3.8" -files = [ - {file = "tokenize_rt-5.2.0-py2.py3-none-any.whl", hash = "sha256:b79d41a65cfec71285433511b50271b05da3584a1da144a0752e9c621a285289"}, - {file = "tokenize_rt-5.2.0.tar.gz", hash = "sha256:9fe80f8a5c1edad2d3ede0f37481cc0cc1538a2f442c9c2f9e4feacd2792d054"}, -] - [[package]] name = "tomli" version = "2.0.1" @@ -1376,54 +880,6 @@ platformdirs = ">=3.9.1,<5" docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] -[[package]] -name = "wemake-python-styleguide" -version = "0.18.0" -description = "The strictest and most opinionated python linter ever" -optional = false -python-versions = ">=3.8.1,<4.0" -files = [ - {file = "wemake_python_styleguide-0.18.0-py3-none-any.whl", hash = "sha256:2219be145185edcd5e01f4ce49e3dea11acc34f2c377face0c175bb6ea6ac988"}, - {file = "wemake_python_styleguide-0.18.0.tar.gz", hash = "sha256:69139858cf5b2a9ba09dac136e2873a4685515768f68fdef2684ebefd7b1dafd"}, -] - -[package.dependencies] -astor = ">=0.8,<0.9" -attrs = "*" -darglint = ">=1.2,<2.0" -flake8 = ">5" -flake8-bandit = ">=4.1,<5.0" -flake8-broken-line = ">=1.0,<2.0" -flake8-bugbear = ">=23.5,<24.0" -flake8-commas = ">=2.0,<3.0" -flake8-comprehensions = ">=3.1,<4.0" -flake8-debugger = ">=4.0,<5.0" -flake8-docstrings = ">=1.3,<2.0" -flake8-eradicate = ">=1.5,<2.0" -flake8-isort = ">=6.0,<7.0" -flake8-quotes = ">=3.0,<4.0" -flake8-rst-docstrings = ">=0.3,<0.4" -flake8-string-format = ">=0.3,<0.4" -pep8-naming = ">=0.13,<0.14" -pygments = ">=2.4,<3.0" -setuptools = "*" -typing_extensions = ">=4.0,<5.0" - -[[package]] -name = "yesqa" -version = "1.5.0" -description = "Automatically remove unnecessary `# noqa` comments." -optional = false -python-versions = ">=3.8" -files = [ - {file = "yesqa-1.5.0-py2.py3-none-any.whl", hash = "sha256:600c6d6e59aff9d85422c28c0d0ff016c040f4eb653636632c18fb6c43453e00"}, - {file = "yesqa-1.5.0.tar.gz", hash = "sha256:209c17274f3c0cc22195ddb26f93df3523634d0756f756913ed05cba970efad9"}, -] - -[package.dependencies] -flake8 = ">=3.9" -tokenize-rt = ">=2.1" - [[package]] name = "zipp" version = "3.19.2" @@ -1442,4 +898,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.8.1" -content-hash = "c5df94b76c7e3da07b5e7ead8dd62c7eefc574199902490ca3d9e6a5ac38b5fe" +content-hash = "91379e5e644cac99476ff46ddfed9ae5c205e8c415d3f558701984dd5089cec7" diff --git a/pyproject.toml b/pyproject.toml index 46e3458..a4347f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,7 @@ [tool.poetry] name = "taskiq-pipelines" -version = "0.1.1" +# The version is set automatically by the CI/CD pipeline +version = "0.0.0" description = "Taskiq pipelines for task chaining." authors = ["Pavel Kirilin "] readme = "README.md" @@ -29,19 +30,15 @@ taskiq = ">=0.11.0, <1" typing-extensions = "^4.3.0" pydantic = "^2" -[tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] pytest = "^7" -flake8 = "^6" black = { version = "^22.6.0", allow-prereleases = true } -autoflake = "^1.4" pytest-cov = "^3.0.0" anyio = "^3.6.1" pre-commit = "^2.20.0" -isort = "^5.10.1" -yesqa = "^1.4.0" -wemake-python-styleguide = "^0.18" mypy = "^1" pytest-xdist = { version = "^2.5.0", extras = ["psutil"] } +ruff = "^0.5.6" [tool.mypy] strict = true @@ -62,3 +59,71 @@ multi_line_output = 3 [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" + +[tool.ruff] +# List of enabled rulsets. +# See https://docs.astral.sh/ruff/rules/ for more information. +lint.select = [ + "E", # Error + "F", # Pyflakes + "W", # Pycodestyle + "C90", # McCabe complexity + "I", # Isort + "N", # pep8-naming + "D", # Pydocstyle + "ANN", # Pytype annotations + "S", # Bandit + "B", # Bugbear + "COM", # Commas + "C4", # Comprehensions + "ISC", # Implicit string concat + "PIE", # Unnecessary code + "T20", # Catch prints + "PYI", # validate pyi files + "Q", # Checks for quotes + "RSE", # Checks raise statements + "RET", # Checks return statements + "SLF", # Self checks + "SIM", # Simplificator + "PTH", # Pathlib checks + "ERA", # Checks for commented out code + "PL", # PyLint checks + "RUF", # Specific to Ruff checks +] +lint.ignore = [ + "D105", # Missing docstring in magic method + "D107", # Missing docstring in __init__ + "D212", # Multi-line docstring summary should start at the first line + "D401", # First line should be in imperative mood + "D104", # Missing docstring in public package + "D100", # Missing docstring in public module + "ANN102", # Missing type annotation for self in method + "ANN101", # Missing type annotation for argument + "ANN401", # typing.Any are disallowed in `**kwargs + "PLR0913", # Too many arguments for function call + "D106", # Missing docstring in public nested class + "SLF001", # Private member accessed +] +exclude = [".venv/"] +lint.mccabe = { max-complexity = 10 } +line-length = 88 + +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "S101", # Use of assert detected + "S301", # Use of pickle detected + "D103", # Missing docstring in public function + "SLF001", # Private member accessed + "S311", # Standard pseudo-random generators are not suitable for security/cryptographic purposes + "D101", # Missing docstring in public class +] + +[tool.ruff.lint.pydocstyle] +convention = "pep257" +ignore-decorators = ["typing.overload"] + +[tool.ruff.lint.pylint] +allow-magic-value-types = ["int", "str", "float"] + +[tool.ruff.lint.flake8-bugbear] +extend-immutable-calls = ["taskiq_dependencies.Depends", "taskiq.TaskiqDepends"] diff --git a/taskiq_pipelines/abc.py b/taskiq_pipelines/abc.py index 1ad0eea..2259806 100644 --- a/taskiq_pipelines/abc.py +++ b/taskiq_pipelines/abc.py @@ -1,16 +1,15 @@ from abc import ABC, abstractmethod -from typing import Any, Dict, Type, TypeVar +from typing import Any, Dict, Type from taskiq import AsyncBroker, TaskiqResult - -_T = TypeVar("_T") # noqa: WPS111 +from typing_extensions import ClassVar class AbstractStep(ABC): """Abstract pipeline step.""" _step_name: str - _known_steps: "Dict[str, Type[AbstractStep]]" = {} + _known_steps: ClassVar[Dict[str, Type["AbstractStep"]]] = {} def __init_subclass__(cls, step_name: str, **kwargs: Any) -> None: super().__init_subclass__(**kwargs) diff --git a/taskiq_pipelines/exceptions.py b/taskiq_pipelines/exceptions.py index 7972ba3..d301bcb 100644 --- a/taskiq_pipelines/exceptions.py +++ b/taskiq_pipelines/exceptions.py @@ -5,7 +5,7 @@ class PipelineError(TaskiqError): """Generic pipeline error.""" -class AbortPipeline(PipelineError): +class AbortPipeline(PipelineError): # noqa: N818 """ Abort curret pipeline execution. diff --git a/taskiq_pipelines/middleware.py b/taskiq_pipelines/middleware.py index 79bee0a..49692d5 100644 --- a/taskiq_pipelines/middleware.py +++ b/taskiq_pipelines/middleware.py @@ -15,7 +15,7 @@ class PipelineMiddleware(TaskiqMiddleware): """Pipeline middleware.""" - async def post_save( # noqa: C901, WPS210, WPS212 + async def post_save( # noqa: PLR0911 self, message: "TaskiqMessage", result: "TaskiqResult[Any]", diff --git a/taskiq_pipelines/pipeliner.py b/taskiq_pipelines/pipeliner.py index 094ffda..a328b50 100644 --- a/taskiq_pipelines/pipeliner.py +++ b/taskiq_pipelines/pipeliner.py @@ -114,7 +114,7 @@ def call_next( """ self.steps.append( DumpedStep( - step_type=SequentialStep._step_name, # noqa: WPS437 + step_type=SequentialStep._step_name, step_data=SequentialStep.from_task( task=task, param_name=param_name, @@ -170,7 +170,7 @@ def call_after( """ self.steps.append( DumpedStep( - step_type=SequentialStep._step_name, # noqa: WPS437 + step_type=SequentialStep._step_name, step_data=SequentialStep.from_task( task=task, param_name=EMPTY_PARAM_NAME, @@ -239,7 +239,7 @@ def map( """ self.steps.append( DumpedStep( - step_type=MapperStep._step_name, # noqa: WPS437 + step_type=MapperStep._step_name, step_data=MapperStep.from_task( task=task, param_name=param_name, @@ -311,7 +311,7 @@ def filter( """ self.steps.append( DumpedStep( - step_type=FilterStep._step_name, # noqa: WPS437 + step_type=FilterStep._step_name, step_data=FilterStep.from_task( task=task, param_name=param_name, diff --git a/taskiq_pipelines/steps/__init__.py b/taskiq_pipelines/steps/__init__.py index 1a45a65..abad876 100644 --- a/taskiq_pipelines/steps/__init__.py +++ b/taskiq_pipelines/steps/__init__.py @@ -11,7 +11,7 @@ def parse_step(step_type: str, step_data: Dict[str, Any]) -> AbstractStep: - step_cls = AbstractStep._known_steps.get(step_type) # noqa: WPS437 + step_cls = AbstractStep._known_steps.get(step_type) if step_cls is None: logger.warning(f"Unknown step type: {step_type}") raise ValueError("Unknown step type.") diff --git a/taskiq_pipelines/steps/filter.py b/taskiq_pipelines/steps/filter.py index f8ffe4e..5c4edad 100644 --- a/taskiq_pipelines/steps/filter.py +++ b/taskiq_pipelines/steps/filter.py @@ -13,7 +13,7 @@ @async_shared_broker.task(task_name="taskiq_pipelines.shared.filter_tasks") -async def filter_tasks( # noqa: C901, WPS210, WPS231 +async def filter_tasks( task_ids: List[str], parent_task_id: str, check_interval: float, @@ -43,7 +43,7 @@ async def filter_tasks( # noqa: C901, WPS210, WPS231 ordered_ids = task_ids[:] tasks_set = set(task_ids) while tasks_set: - for task_id in task_ids: # noqa: WPS327 + for task_id in task_ids: if await context.broker.result_backend.is_result_ready(task_id): try: tasks_set.remove(task_id) @@ -54,9 +54,9 @@ async def filter_tasks( # noqa: C901, WPS210, WPS231 results = await context.broker.result_backend.get_result(parent_task_id) filtered_results = [] - for task_id, value in zip( # type: ignore # noqa: WPS352, WPS440 + for task_id, value in zip( ordered_ids, - results.return_value, + results.return_value, # type: ignore ): result = await context.broker.result_backend.get_result(task_id) if result.is_err: @@ -117,15 +117,21 @@ async def act( else: task = await kicker.kiq(item, **self.additional_kwargs) sub_task_ids.append(task.task_id) - await filter_tasks.kicker().with_task_id(task_id).with_broker( - broker, - ).with_labels( - **{CURRENT_STEP: step_number, PIPELINE_DATA: pipe_data}, # type: ignore - ).kiq( - sub_task_ids, - parent_task_id, - check_interval=self.check_interval, - skip_errors=self.skip_errors, + await ( + filter_tasks.kicker() + .with_task_id(task_id) + .with_broker( + broker, + ) + .with_labels( + **{CURRENT_STEP: step_number, PIPELINE_DATA: pipe_data}, # type: ignore + ) + .kiq( + sub_task_ids, + parent_task_id, + check_interval=self.check_interval, + skip_errors=self.skip_errors, + ) ) @classmethod @@ -151,11 +157,8 @@ def from_task( :param additional_kwargs: additional function's kwargs. :return: new mapper step. """ - if isinstance(task, AsyncTaskiqDecoratedTask): - kicker = task.kicker() - else: - kicker = task - message = kicker._prepare_message() # noqa: WPS437 + kicker = task.kicker() if isinstance(task, AsyncTaskiqDecoratedTask) else task + message = kicker._prepare_message() return FilterStep( task_name=message.task_name, labels=message.labels, diff --git a/taskiq_pipelines/steps/mapper.py b/taskiq_pipelines/steps/mapper.py index 8bcbae4..d663ae8 100644 --- a/taskiq_pipelines/steps/mapper.py +++ b/taskiq_pipelines/steps/mapper.py @@ -19,7 +19,7 @@ @async_shared_broker.task(task_name="taskiq_pipelines.shared.wait_tasks") -async def wait_tasks( # noqa: C901, WPS231 +async def wait_tasks( task_ids: List[str], check_interval: float, skip_errors: bool = True, @@ -45,7 +45,7 @@ async def wait_tasks( # noqa: C901, WPS231 ordered_ids = task_ids[:] tasks_set = set(task_ids) while tasks_set: - for task_id in task_ids: # noqa: WPS327 + for task_id in task_ids: if await context.broker.result_backend.is_result_ready(task_id): try: tasks_set.remove(task_id) @@ -55,7 +55,7 @@ async def wait_tasks( # noqa: C901, WPS231 await asyncio.sleep(check_interval) results = [] - for task_id in ordered_ids: # noqa: WPS440 + for task_id in ordered_ids: result = await context.broker.result_backend.get_result(task_id) if result.is_err: if skip_errors: @@ -154,11 +154,8 @@ def from_task( :param additional_kwargs: additional function's kwargs. :return: new mapper step. """ - if isinstance(task, AsyncTaskiqDecoratedTask): - kicker = task.kicker() - else: - kicker = task - message = kicker._prepare_message() # noqa: WPS437 + kicker = task.kicker() if isinstance(task, AsyncTaskiqDecoratedTask) else task + message = kicker._prepare_message() return MapperStep( task_name=message.task_name, labels=message.labels, diff --git a/taskiq_pipelines/steps/sequential.py b/taskiq_pipelines/steps/sequential.py index 37e1656..7b10fb0 100644 --- a/taskiq_pipelines/steps/sequential.py +++ b/taskiq_pipelines/steps/sequential.py @@ -91,11 +91,8 @@ def from_task( :param additional_kwargs: additional kwargs to task. :return: new sequential step. """ - if isinstance(task, AsyncTaskiqDecoratedTask): - kicker = task.kicker() - else: - kicker = task - message = kicker._prepare_message() # noqa: WPS437 + kicker = task.kicker() if isinstance(task, AsyncTaskiqDecoratedTask) else task + message = kicker._prepare_message() return SequentialStep( task_name=message.task_name, labels=message.labels,