Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
name: Release python package

on:
push:
tags:
- "*"
release:
types:
- released

jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v5
with:
python-version: "3.9"
- name: Install deps
run: poetry install
- name: Set version
run: poetry version "${{ github.ref_name }}"
persist-credentials: false
- uses: astral-sh/setup-uv@v7
with:
enable-cache: false
python-version: "3.12"
version: "latest"
- run: uv version "${GITHUB_REF_NAME}"
- run: uv build
- name: Release package
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish --build
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: uv publish
39 changes: 24 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
name: Testing package

on:
- push
- pull_request
pull_request:
paths-ignore:
- '*.md'
push:
paths-ignore:
- '*.md'

permissions:
actions: read
contents: read
pull-requests: read


jobs:
lint:
strategy:
matrix:
cmd:
- black
- mypy
- ruff
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@v4
- uses: actions/checkout@v5
with:
persist-credentials: false
- id: setup-uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.9"
cache: "poetry"
enable-cache: true
cache-suffix: 3.11
version: "latest"
python-version: 3.11
- name: Install deps
run: poetry install
run: uv sync --all-extras
- name: Run lint check
run: poetry run pre-commit run -a ${{ matrix.cmd }}
run: uv run pre-commit run -a ${{ matrix.cmd }}
20 changes: 15 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,45 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v6.0.0
hooks:
- id: check-ast
- id: trailing-whitespace
- id: check-toml
- id: end-of-file-fixer

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

- repo: https://github.com/crate-ci/typos
rev: v1.38.1
hooks:
- id: typos

- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets

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

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

- id: ruff
name: Run ruff lints
entry: poetry run ruff
entry: uv run ruff
language: system
pass_filenames: false
types: [python]
Expand Down
906 changes: 0 additions & 906 deletions poetry.lock

This file was deleted.

48 changes: 26 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
[tool.poetry]
[project]
name = "taskiq-fastapi"
description = "FastAPI integration for taskiq"
authors = ["Taskiq team <taskiq@no-reply.com>"]
maintainers = ["Taskiq team <taskiq@no-reply.com>"]
version = "0.0.0"
readme = "README.md"
license = "LICENSE"
license = "MIT"
license-files = ["LICENSE"]
authors = [{ name = "Taskiq team", email = "taskiq@no-reply.com" }]
maintainers = [{ name = "Taskiq team", email = "taskiq@no-reply.com" }]
version = "0.0.0"
requires-python = ">=3.10"
classifiers = [
"Typing :: Typed",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Topic :: System :: Networking",
"Development Status :: 3 - Alpha",
]
keywords = ["taskiq", "tasks", "distributed", "async", "fastapi"]
packages = [{ include = "taskiq_fastapi" }]
dependencies = ["taskiq>=0.8.0", "fastapi>=0.93.0"]

[tool.poetry.dependencies]
python = "^3.8.1"
taskiq = "^0,>=0.8.0"
fastapi = ">=0.93.0"
[dependency-groups]
dev = [
"pre-commit>=4.4.0",
# lint
"ruff>=0.14.5",
"black>=25.11.0",
# type check
"mypy>=1.18.2",
# tests
"pytest>=9.0.1",
"pytest-cov>=7.0.0",
"coverage>=7.11.3",
]

[tool.poetry.group.dev.dependencies]
mypy = "^1"
pre-commit = "^2.20.0"
coverage = "^6.4.2"
black = "^23.1.0"
ruff = "^0.6"
[tool.uv_build.targets.wheel]
packages = ["taskiq_fastapi"]

[tool.mypy]
strict = true
Expand All @@ -47,10 +54,6 @@ allow_untyped_decorators = true
warn_return_any = false
warn_unused_ignores = false

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
# List of enabled rulsets.
# See https://docs.astral.sh/ruff/rules/ for more information.
Expand Down Expand Up @@ -80,6 +83,7 @@ lint.select = [
"ERA", # Checks for commented out code
"PL", # PyLint checks
"RUF", # Specific to Ruff checks
"UP", # Pyupgrade: modernize syntax & type hints
]
lint.ignore = [
"D105", # Missing docstring in magic method
Expand Down
1 change: 1 addition & 0 deletions taskiq_fastapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""FastAPI integration for Taskiq project."""

from taskiq_fastapi.initializator import init, populate_dependency_context

__all__ = ["init", "populate_dependency_context"]
9 changes: 5 additions & 4 deletions taskiq_fastapi/initializator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
from typing import Any, Awaitable, Callable, Mapping, Optional, Union
from collections.abc import Awaitable, Callable, Mapping
from typing import Any

from fastapi import FastAPI, Request
from starlette.requests import HTTPConnection
Expand All @@ -9,7 +10,7 @@

def startup_event_generator(
broker: AsyncBroker,
app_or_path: Union[str, FastAPI],
app_or_path: str | FastAPI,
) -> Callable[[TaskiqState], Awaitable[None]]:
"""
Generate shutdown event.
Expand Down Expand Up @@ -67,7 +68,7 @@ async def shutdown(state: TaskiqState) -> None:
return shutdown


def init(broker: AsyncBroker, app_or_path: Union[str, FastAPI]) -> None:
def init(broker: AsyncBroker, app_or_path: str | FastAPI) -> None:
"""
Add taskiq startup events.

Expand Down Expand Up @@ -95,7 +96,7 @@ def init(broker: AsyncBroker, app_or_path: Union[str, FastAPI]) -> None:
def populate_dependency_context(
broker: AsyncBroker,
app: FastAPI,
asgi_state: Optional[Mapping[str, Any]] = None,
asgi_state: Mapping[str, Any] | None = None,
) -> None:
"""
Populate dependency context.
Expand Down
Loading