Skip to content

Commit

Permalink
Replaced flake with ruff + github flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rius committed Aug 14, 2024
1 parent 4d6fa7c commit c3dc2bf
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 72 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ jobs:
matrix:
cmd:
- black
- flake8
- isort
- ruff
- mypy
- autoflake
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -20,7 +18,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.11"
cache: "poetry"
- name: Install deps
run: poetry install
Expand All @@ -43,7 +41,7 @@ jobs:
- 5672:5672
strategy:
matrix:
py_version: ["3.8", "3.9", "3.10", "3.11"]
py_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
Expand Down
45 changes: 16 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,39 @@ repos:
hooks:
- id: check-ast
- id: trailing-whitespace
exclude: 'README.md'
- id: check-toml
- id: end-of-file-fixer

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.1.0
hooks:
- id: add-trailing-comma
- id: add-trailing-comma

- repo: local
hooks:
- id: black
name: Format with Black
entry: black
entry: poetry run black
language: system
types: [python]

- id: autoflake
name: autoflake
entry: autoflake
language: system
types: [ python ]
args: [ --in-place, --remove-all-unused-imports, --remove-duplicate-keys ]

- id: isort
name: isort
entry: isort
language: system
types: [ python ]

- id: flake8
name: Check with Flake8
entry: flake8
- id: ruff
name: Run ruff lints
entry: poetry run ruff
language: system
pass_filenames: false
types: [ python ]
args: [--count, taskiq_aio_pika]
types: [python]
args:
- "check"
- "--fix"
- "taskiq_aio_pika"
- "tests"

- id: mypy
name: Validate types with MyPy
entry: mypy
language: system
types: [ python ]

- id: yesqa
name: Remove usless noqa
entry: yesqa
entry: poetry run mypy
language: system
types: [ python ]
types: [python]
args:
- taskiq_aio_pika
- tests
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You can send delayed messages and set priorities to messages using labels.

To send delayed message, you have to specify
delay label. You can do it with `task` decorator,
or by using kicker.
or by using kicker.
In this type of delay we are using additional queue with `expiration` parameter and after with time message will be deleted from `delay` queue and sent to the main taskiq queue.
For example:

Expand Down Expand Up @@ -58,9 +58,9 @@ To send delayed message you can install `rabbitmq-delayed-message-exchange`
plugin https://github.com/rabbitmq/rabbitmq-delayed-message-exchange.

And you need to configure you broker.
There is `delayed_message_exchange_plugin` `AioPikaBroker` parameter and it must be `True` to turn on delayed message functionality.
There is `delayed_message_exchange_plugin` `AioPikaBroker` parameter and it must be `True` to turn on delayed message functionality.

The delay plugin can handle tasks with different delay times well, and the delay based on dead letter queue is suitable for tasks with the same delay time.
The delay plugin can handle tasks with different delay times well, and the delay based on dead letter queue is suitable for tasks with the same delay time.
For example:

```python
Expand Down
63 changes: 34 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ aio-pika = "^9.0"
[tool.poetry.dev-dependencies]
pytest = "^7.0"
isort = "^5.10.1"
mypy = "^0.971"
mypy = "^1"
black = "^22.6.0"
pre-commit = "^2.20.0"
pytest-xdist = { version = "^2.5.0", extras = ["psutil"] }
Expand All @@ -45,6 +45,7 @@ show_error_codes = true
implicit_reexport = true
allow_untyped_decorators = true
warn_return_any = false
explicit_package_bases = true

[tool.isort]
profile = "black"
Expand Down Expand Up @@ -117,7 +118,7 @@ convention = "pep257"
ignore-decorators = ["typing.overload"]

[tool.ruff.lint.pylint]
allow-magic-value-types = ["int", "str", "float"]
allow-magic-value-types = ["int", "str", "float", "bytes"]

[tool.ruff.lint.flake8-bugbear]
extend-immutable-calls = ["taskiq_dependencies.Depends", "taskiq.TaskiqDepends"]
6 changes: 3 additions & 3 deletions taskiq_aio_pika/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from aio_pika.abc import AbstractChannel, AbstractQueue, AbstractRobustConnection
from taskiq import AckableMessage, AsyncBroker, AsyncResultBackend, BrokerMessage

_T = TypeVar("_T") # noqa: WPS111
_T = TypeVar("_T")

logger = getLogger("taskiq.aio_pika_broker")

Expand Down Expand Up @@ -35,7 +35,7 @@ def parse_val(
class AioPikaBroker(AsyncBroker):
"""Broker that works with RabbitMQ."""

def __init__( # noqa: WPS211
def __init__(
self,
url: Optional[str] = None,
result_backend: Optional[AsyncResultBackend[_T]] = None,
Expand Down Expand Up @@ -119,7 +119,7 @@ def __init__( # noqa: WPS211
self.write_channel: Optional[AbstractChannel] = None
self.read_channel: Optional[AbstractChannel] = None

async def startup(self) -> None: # noqa: WPS217
async def startup(self) -> None:
"""Create exchange and queue on startup."""
await super().startup()
self.write_conn = await connect_robust(
Expand Down
Empty file added tests/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion tests/test_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async def get_first_task(broker: AioPikaBroker) -> AckableMessage: # type: igno
:param broker: async message broker.
:return: first message from listen method
"""
async for message in broker.listen():
async for message in broker.listen(): # noqa: RET503
return message


Expand Down

0 comments on commit c3dc2bf

Please sign in to comment.