Skip to content

Commit ec76b18

Browse files
authored
Merge pull request #29 from taskiq-python/feature/uv
2 parents 2d50431 + 56563c1 commit ec76b18

13 files changed

Lines changed: 1337 additions & 1676 deletions

File tree

.github/workflows/release.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,31 @@ on:
88
jobs:
99
deploy:
1010
runs-on: ubuntu-latest
11+
environment:
12+
name: release
13+
permissions:
14+
id-token: write
15+
env:
16+
UV_SYSTEM_PYTHON: 1
1117
steps:
12-
- uses: actions/checkout@v2
13-
- name: Install poetry
14-
run: pipx install poetry
15-
- name: Set up Python
16-
uses: actions/setup-python@v4
18+
- uses: actions/checkout@v5
1719
with:
18-
python-version: "3.11"
19-
- name: Install deps
20-
run: poetry install
21-
- name: Set version
22-
run: poetry version "${{ github.ref_name }}"
20+
persist-credentials: false
21+
fetch-depth: 0
22+
- name: Setup python
23+
uses: actions/setup-python@v6
24+
with:
25+
python-version: '3.14'
26+
- id: setup-uv
27+
name: Setup UV
28+
uses: astral-sh/setup-uv@v7
29+
with:
30+
enable-cache: true
31+
cache-suffix: '3.14'
32+
github-token: ${{ github.token }}
33+
version: "3.14"
34+
- run: uv build
2335
- name: Release package
2436
env:
25-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
26-
run: poetry publish --build
37+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
38+
run: uv publish

.github/workflows/test.yml

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,69 @@
11
name: Testing package
22

3-
on: push
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
actions: read
8+
contents: read
9+
pull-requests: read
410

511
jobs:
612
lint:
713
strategy:
814
matrix:
9-
cmd:
10-
- black
11-
- mypy
12-
- ruff
15+
cmd: ["black", "ruff", "mypy"]
1316
runs-on: ubuntu-latest
1417
steps:
15-
- uses: actions/checkout@v2
16-
- name: Install poetry
17-
run: pipx install poetry
18-
- name: Set up Python
19-
uses: actions/setup-python@v4
18+
- uses: actions/checkout@v5
19+
with:
20+
persist-credentials: false
21+
fetch-depth: 0
22+
- id: setup-uv
23+
uses: astral-sh/setup-uv@v7
2024
with:
21-
python-version: "3.11"
22-
cache: "poetry"
25+
enable-cache: true
26+
cache-suffix: 3.11
27+
version: "latest"
28+
python-version: 3.11
2329
- name: Install deps
24-
run: poetry install
30+
run: uv sync --all-extras
2531
- name: Run lint check
26-
run: poetry run pre-commit run -a ${{ matrix.cmd }}
32+
run: uv run pre-commit run -a ${{ matrix.cmd }}
2733
pytest:
28-
permissions:
29-
checks: write
30-
pull-requests: write
31-
contents: write
3234
strategy:
3335
matrix:
34-
py_version: ["3.9", "3.10", "3.11", "3.12"]
36+
py_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
3537
runs-on: "ubuntu-latest"
38+
env:
39+
UV_SYSTEM_PYTHON: 1
3640
steps:
37-
- uses: actions/checkout@v2
38-
- name: Install poetry
39-
run: pipx install poetry
40-
- name: Set up Python
41-
uses: actions/setup-python@v4
41+
- uses: actions/checkout@v5
42+
with:
43+
persist-credentials: false
44+
fetch-depth: 0
45+
- name: Setup python
46+
uses: actions/setup-python@v6
4247
with:
4348
python-version: "${{ matrix.py_version }}"
44-
cache: "poetry"
49+
- id: setup-uv
50+
name: Setup UV
51+
uses: astral-sh/setup-uv@v7
52+
with:
53+
enable-cache: true
54+
cache-suffix: ${{ matrix.py_version }}
55+
github-token: ${{ github.token }}
56+
version: "latest"
4557
- name: Install deps
46-
run: poetry install
58+
run: uv sync --all-extras --locked
4759
- name: Run pytest check
48-
run: poetry run pytest -vv -n auto --cov="aiohttp_deps" .
60+
run: uv run pytest -vv -n auto --cov="aiohttp_deps" .
4961
- name: Generate report
50-
run: poetry run coverage xml
62+
run: uv run coverage xml
5163
- name: Upload coverage reports to Codecov with GitHub Action
52-
uses: codecov/codecov-action@v3
53-
if: matrix.py_version == '3.9'
64+
uses: codecov/codecov-action@v5
65+
if: matrix.os == 'ubuntu-latest' && matrix.py_version == '3.10'
5466
with:
55-
token: ${{ secrets.CODECOV_TOKEN }}
5667
fail_ci_if_error: false
68+
token: ${{ secrets.CODECOV_TOKEN }}
5769
verbose: true

.pre-commit-config.yaml

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,57 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v2.4.0
5+
rev: v6.0.0
66
hooks:
77
- id: check-ast
88
- id: trailing-whitespace
99
- id: check-toml
1010
- id: end-of-file-fixer
1111

1212
- repo: https://github.com/asottile/add-trailing-comma
13-
rev: v2.1.0
13+
rev: v4.0.0
1414
hooks:
1515
- id: add-trailing-comma
1616

17+
- repo: https://github.com/crate-ci/typos
18+
rev: v1.38.1
19+
hooks:
20+
- id: typos
21+
22+
- repo: https://github.com/Yelp/detect-secrets
23+
rev: v1.5.0
24+
hooks:
25+
- id: detect-secrets
26+
args: [
27+
'--exclude-files', 'README.md',
28+
'--exclude-files', 'tests/.*',
29+
]
30+
1731
- repo: local
1832
hooks:
1933
- id: black
2034
name: Format with Black
21-
entry: poetry run black
22-
language: system
23-
types: [python]
24-
25-
26-
- id: mypy
27-
name: Validate types with MyPy
28-
entry: poetry run mypy
35+
entry: uv run black
2936
language: system
3037
types: [python]
31-
pass_filenames: false
32-
args: [aiohttp_deps]
3338

3439
- id: ruff
3540
name: Run ruff lints
36-
entry: poetry run ruff check
41+
entry: uv run ruff
3742
language: system
3843
pass_filenames: false
3944
types: [python]
4045
args:
46+
- "check"
4147
- "--fix"
4248
- "aiohttp_deps"
4349
- "tests"
50+
51+
- id: mypy
52+
name: Validate types with MyPy
53+
entry: uv run mypy
54+
language: system
55+
pass_filenames: false
56+
types: [python]
57+
args:
58+
- ./aiohttp_deps/

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# AioHTTP deps
66

77

8-
This project was initially created to show the abillities of [taskiq-dependencies](https://github.com/taskiq-python/taskiq-dependencies) project, which is used by [taskiq](https://github.com/taskiq-python/taskiq) to provide you with the best experience of sending distributed tasks.
8+
This project was initially created to show the abilities of [taskiq-dependencies](https://github.com/taskiq-python/taskiq-dependencies) project, which is used by [taskiq](https://github.com/taskiq-python/taskiq) to provide you with the best experience of sending distributed tasks.
99

1010
This project adds [FastAPI](https://github.com/tiangolo/fastapi)-like dependency injection to your [AioHTTP](https://github.com/aio-libs/aiohttp) application and swagger documentation based on types.
1111

@@ -26,7 +26,7 @@ web.run_app(app)
2626
```
2727

2828

29-
If you use mypy, then we have a custom router with propper types.
29+
If you use mypy, then we have a custom router with proper types.
3030

3131

3232
```python
@@ -123,7 +123,7 @@ async def handler() -> web.Response:
123123

124124
This example illustrates how much you can do with this decorator. You
125125
can have multiple content-types for a single status, or you can have different
126-
possble statuses. This function is pretty simple and if you want to make
126+
possible statuses. This function is pretty simple and if you want to make
127127
your own decorator for your responses, it won't be hard.
128128

129129

@@ -289,7 +289,7 @@ async def shop(item_id: str = Depends(Query())) -> web.Response:
289289

290290
the name of the parameter is the same as the name of function parameter.
291291

292-
The Query dependency is acually the same as the Header dependency, so everything about the `Header` dependency also applies to `Query`.
292+
The Query dependency is actually the same as the Header dependency, so everything about the `Header` dependency also applies to `Query`.
293293

294294
## Views
295295

@@ -312,7 +312,7 @@ class MyView(View):
312312

313313
## Forms
314314

315-
Now you can easiy get and validate form data from your request.
315+
Now you can easily get and validate form data from your request.
316316
To make the magic happen, please add `arbitrary_types_allowed` to the config of your model.
317317

318318

@@ -370,7 +370,7 @@ You can check how this thing can be used in our [examples/swagger_auth.py](https
370370
Sometimes for tests you don't want to calculate actual functions
371371
and you want to pass another functions instead.
372372

373-
To do so, you can add "dependency_overrides" or "values_overrides" to the aplication's state.
373+
To do so, you can add "dependency_overrides" or "values_overrides" to the application's state.
374374
These values should be dicts. The keys for these values can be found in `aiohttp_deps.keys` module.
375375

376376
Here's an example.
@@ -388,7 +388,7 @@ class MyView(View):
388388
Imagine you have a handler that depends on some function,
389389
but instead of `1` you want to have `2` in your tests.
390390

391-
To do it, jsut add `dependency_overrides` somewhere,
391+
To do it, just add `dependency_overrides` somewhere,
392392
where you create your application. And make sure that keys
393393
of that dict are actual function that are being replaced.
394394

aiohttp_deps/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
from aiohttp_deps.view import View
1111

1212
__all__ = [
13-
"init",
14-
"setup_swagger",
15-
"extra_openapi",
16-
"Header",
13+
"DEPENDENCY_OVERRIDES_KEY",
14+
"VALUES_OVERRIDES_KEY",
1715
"Depends",
18-
"Router",
19-
"View",
20-
"Json",
21-
"Query",
16+
"ExtraOpenAPI",
2217
"Form",
18+
"Header",
19+
"Json",
2320
"Path",
24-
"ExtraOpenAPI",
21+
"Query",
22+
"Router",
23+
"View",
24+
"extra_openapi",
25+
"init",
2526
"openapi_response",
26-
"DEPENDENCY_OVERRIDES_KEY",
27-
"VALUES_OVERRIDES_KEY",
27+
"setup_swagger",
2828
]

aiohttp_deps/swagger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
_T = TypeVar("_T")
2626

2727
REF_TEMPLATE = "#/components/schemas/{model}"
28-
SWAGGER_HTML_TEMPALTE = """
28+
SWAGGER_HTML_TEMPLATE = """
2929
<html lang="en">
3030
3131
<head>
@@ -333,7 +333,7 @@ async def event_handler(app: web.Application) -> None: # noqa: C901
333333
app.router.add_get(
334334
swagger_ui_url,
335335
_get_swagger_handler(
336-
SWAGGER_HTML_TEMPALTE.replace("{schema_url}", schema_url),
336+
SWAGGER_HTML_TEMPLATE.replace("{schema_url}", schema_url),
337337
),
338338
)
339339

aiohttp_deps/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,6 @@ def __call__(self) -> None:
422422
"""
423423
This method is called when dependency is resolved.
424424
425-
It's empty, becuase it's used only by the `setup_swagger` function and
425+
It's empty, because it's used only by the `setup_swagger` function and
426426
there is no actual dependency.
427427
"""

aiohttp_deps/view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class View(web.View):
1212
Custom View.
1313
1414
If you're going to use dependency injection
15-
in handlers, please subclass this View instad of
15+
in handlers, please subclass this View instead of
1616
the default View from AioHTTP.
1717
"""
1818

0 commit comments

Comments
 (0)