Skip to content

Commit 76e03ad

Browse files
authored
Merge branch 'main' into dependabot/github_actions/actions/upload-artifact-6
2 parents c17ad98 + a4c332f commit 76e03ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+189
-92
lines changed

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- synchronize
88

99
env:
10-
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
10+
# Forks and Dependabot don't have access to secrets
11+
HAS_SECRETS: ${{ secrets.PRE_COMMIT != '' }}
1112

1213
jobs:
1314
pre-commit:
@@ -19,16 +20,23 @@ jobs:
1920
run: echo "$GITHUB_CONTEXT"
2021
- uses: actions/checkout@v6
2122
name: Checkout PR for own repo
22-
if: env.IS_FORK == 'false'
23+
if: env.HAS_SECRETS == 'true'
2324
with:
24-
# To be able to commit it needs more than the last commit
25+
# To be able to commit it needs to fetch the head of the branch, not the
26+
# merge commit
2527
ref: ${{ github.head_ref }}
28+
# And it needs the full history to be able to compute diffs
29+
fetch-depth: 0
2630
# A token other than the default GITHUB_TOKEN is needed to be able to trigger CI
2731
token: ${{ secrets.PRE_COMMIT }}
2832
# pre-commit lite ci needs the default checkout configs to work
2933
- uses: actions/checkout@v6
3034
name: Checkout PR for fork
31-
if: env.IS_FORK == 'true'
35+
if: env.HAS_SECRETS == 'false'
36+
with:
37+
# To be able to commit it needs the head branch of the PR, the remote one
38+
ref: ${{ github.event.pull_request.head.sha }}
39+
fetch-depth: 0
3240
- name: Set up Python
3341
uses: actions/setup-python@v6
3442
with:
@@ -44,15 +52,12 @@ jobs:
4452
run: |
4553
uv venv
4654
uv pip install -r requirements.txt
47-
- name: Run pre-commit
55+
- name: Run prek - pre-commit
4856
id: precommit
49-
run: |
50-
# Fetch the base branch for comparison
51-
git fetch origin ${{ github.base_ref }}
52-
uvx pre-commit run --from-ref origin/${{ github.base_ref }} --to-ref HEAD --show-diff-on-failure
57+
run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
5358
continue-on-error: true
5459
- name: Commit and push changes
55-
if: env.IS_FORK == 'false'
60+
if: env.HAS_SECRETS == 'true'
5661
run: |
5762
git config user.name "github-actions[bot]"
5863
git config user.email "github-actions[bot]@users.noreply.github.com"
@@ -64,7 +69,7 @@ jobs:
6469
git push
6570
fi
6671
- uses: pre-commit-ci/lite-action@v1.1.0
67-
if: env.IS_FORK == 'true'
72+
if: env.HAS_SECRETS == 'false'
6873
with:
6974
msg: 🎨 Auto format
7075
- name: Error out on pre-commit errors

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
strategy:
2828
matrix:
2929
python-version:
30-
- "3.8"
3130
- "3.9"
3231
- "3.10"
3332
- "3.11"
@@ -90,7 +89,7 @@ jobs:
9089
- uses: actions/checkout@v6
9190
- uses: actions/setup-python@v6
9291
with:
93-
python-version: '3.8'
92+
python-version: '3.13'
9493
- name: Setup uv
9594
uses: astral-sh/setup-uv@v7
9695
with:

.pre-commit-config.yaml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@ repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
55
rev: v6.0.0
66
hooks:
7-
- id: check-added-large-files
8-
- id: check-toml
9-
- id: check-yaml
7+
- id: check-added-large-files
8+
- id: check-toml
9+
- id: check-yaml
1010
args:
1111
- --unsafe
12-
- id: end-of-file-fixer
13-
- id: trailing-whitespace
14-
- repo: https://github.com/astral-sh/ruff-pre-commit
15-
rev: v0.14.5
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+
15+
- repo: local
1616
hooks:
17-
- id: ruff
18-
args:
19-
- --fix
20-
- id: ruff-format
17+
- id: local-ruff-check
18+
name: ruff check
19+
entry: uv run ruff check --force-exclude --fix --exit-non-zero-on-fix
20+
require_serial: true
21+
language: unsupported
22+
types: [python]
23+
24+
- id: local-ruff-format
25+
name: ruff format
26+
entry: uv run ruff format --force-exclude --exit-non-zero-on-format
27+
require_serial: true
28+
language: unsupported
29+
types: [python]

asyncer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.0.11"
1+
__version__ = "0.0.12"
22

33
from ._main import PendingValueException as PendingValueException
44
from ._main import SoonValue as SoonValue

asyncer/_main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import functools
22
import sys
3+
from collections.abc import Awaitable, Coroutine
34
from importlib import import_module
45
from typing import (
56
Any,
6-
Awaitable,
77
Callable,
8-
Coroutine,
9-
Dict,
108
Generic,
119
Optional,
1210
TypeVar,
@@ -200,7 +198,7 @@ class ExtendedTaskGroup(LibTaskGroup, TaskGroup): # type: ignore
200198
def runnify(
201199
async_function: Callable[T_ParamSpec, Coroutine[Any, Any, T_Retval]],
202200
backend: str = "asyncio",
203-
backend_options: Optional[Dict[str, Any]] = None,
201+
backend_options: Optional[dict[str, Any]] = None,
204202
) -> Callable[T_ParamSpec, T_Retval]:
205203
"""
206204
Take an async function and create a regular (blocking) function that receives the

docs/contributing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ Go into the docs director at `docs/`:
104104
$ cd docs/
105105
```
106106

107-
Then run `mkdocs` in that directory:
107+
Then run `zensical` in that directory:
108108

109109
```console
110-
$ mkdocs serve --dev-addr 8008
110+
$ zensical serve --dev-addr 8008
111111
```
112112

113113
///
@@ -133,7 +133,7 @@ Completion will take effect once you restart the terminal.
133133

134134
### Docs Structure
135135

136-
The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a>.
136+
The documentation uses <a href="https://zensical.org" class="external-link" target="_blank">Zensical</a>.
137137

138138
And there are extra tools/scripts in place in `./scripts/docs.py`.
139139

docs/management-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ A PR should have a specific use case that it is solving.
9090
* If the PR is for a feature, it should have docs.
9191
* Unless it's a feature we want to discourage, like support for a corner case that we don't want users to use.
9292
* The docs should include a source example file, not write Python directly in Markdown.
93-
* If the source example(s) file can have different syntax for Python 3.8, 3.9, 3.10, there should be different versions of the file, and they should be shown in tabs in the docs.
93+
* If the source example(s) file can have different syntax for different Python versions, there should be different versions of the file, and they should be shown in tabs in the docs.
9494
* There should be tests testing the source example.
9595
* Before the PR is applied, the new tests should fail.
9696
* After applying the PR, the new tests should pass.

docs/release-notes.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22

33
## Latest Changes
44

5+
### Internal
6+
7+
* 👷 Update secrets check. PR [#446](https://github.com/fastapi/asyncer/pull/446) by [@YuriiMotov](https://github.com/YuriiMotov).
8+
* 🔧 Migrate from Material for MkDocs to Zensical. PR [#445](https://github.com/fastapi/asyncer/pull/445) by [@tiangolo](https://github.com/tiangolo).
9+
* 🔧 Update pre-commit to use local Ruff instead of hook, unpin `prek`. PR [#443](https://github.com/fastapi/asyncer/pull/443) by [@YuriiMotov](https://github.com/YuriiMotov).
10+
11+
## 0.0.12
12+
13+
### Breaking Changes
14+
15+
* ➖ Drop support for Python 3.8. PR [#441](https://github.com/fastapi/asyncer/pull/441) by [@tiangolo](https://github.com/tiangolo).
16+
517
### Docs
618

19+
* 📝 Update code examples to Python 3.9. PR [#442](https://github.com/fastapi/asyncer/pull/442) by [@YuriiMotov](https://github.com/YuriiMotov).
720
* 📝 Relax the warnings as I have been using Asyncer in production for a while (and other teams as well). PR [#424](https://github.com/fastapi/asyncer/pull/424) by [@tiangolo](https://github.com/tiangolo).
821

922
### Internal
1023

24+
* ⬆️ Use prek as a pre-commit alternative. PR [#437](https://github.com/fastapi/asyncer/pull/437) by [@YuriiMotov](https://github.com/YuriiMotov).
1125
* 👷 Configure coverage, error on main tests, don't wait for Smokeshow. PR [#435](https://github.com/fastapi/asyncer/pull/435) by [@YuriiMotov](https://github.com/YuriiMotov).
1226
* 👷 Run Smokeshow always, even on test failures. PR [#434](https://github.com/fastapi/asyncer/pull/434) by [@YuriiMotov](https://github.com/YuriiMotov).
1327
* 🔥 Remove Material for MkDocs Insiders extra files. PR [#432](https://github.com/fastapi/asyncer/pull/432) by [@tiangolo](https://github.com/tiangolo).

docs/tutorial/asyncify.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Let's see a **broken** example first.
1616

1717
Let's see a sync (regular, blocking) function `do_sync_work()`:
1818

19-
{* docs_src/tutorial/asyncify/tutorial001.py ln[8:10] hl[8:10] *}
19+
{* docs_src/tutorial/asyncify/tutorial001_py39.py ln[8:10] hl[8:10] *}
2020

2121
This function could be talking to a database, a remote API, etc. But it doesn't use `await`, it just makes Python wait there without a warning using `time.sleep(1)`.
2222

@@ -26,15 +26,15 @@ Here's the problem.
2626

2727
Let's just call that **slow** sync (regular, blocking) function directly from inside the async code 😱:
2828

29-
{* docs_src/tutorial/asyncify/tutorial001.py hl[14] *}
29+
{* docs_src/tutorial/asyncify/tutorial001_py39.py hl[14] *}
3030

3131
Because that function is not async, but still it makes Python wait there, it will impede any other async code that could have been started from running. It will all have to **just wait** there doing nothing, wasting computation time. 😭
3232

3333
## Use Asyncify
3434

3535
In those cases where you want to run "**sync**" (synchronous, blocking) code **from inside of async** code in a way that is compatible with the rest of the async code you can use **Asyncer**'s `asyncify()`. 🚀
3636

37-
{* docs_src/tutorial/asyncify/tutorial002.py hl[4,13] *}
37+
{* docs_src/tutorial/asyncify/tutorial002_py39.py hl[4,13] *}
3838

3939
`asyncify()` takes the **sync (blocking) function** that you want to call and then returns another **async function** that takes the actual **arguments for the original sync function**.
4040

@@ -44,7 +44,7 @@ Then you can `await` that and get the return value that was **safely** executed
4444

4545
Notice that now the function `do_sync_work` is not an `async` function:
4646

47-
{* docs_src/tutorial/asyncify/tutorial002.py ln[7:9] hl[7:9] *}
47+
{* docs_src/tutorial/asyncify/tutorial002_py39.py ln[7:9] hl[7:9] *}
4848

4949
...it even has a line:
5050

docs/tutorial/first-steps.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Asyncer is based on **AnyIO**, so let's start with a simple example just using *
66

77
Let's start with a simple main async function.
88

9-
{* docs_src/tutorial/first_steps/tutorial001.py ln[9:11] hl[9:10] *}
9+
{* docs_src/tutorial/first_steps/tutorial001_py39.py ln[9:11] hl[9:10] *}
1010

1111
When working with **async** code you normally use `async` and `await`.
1212

@@ -25,13 +25,13 @@ The function `do_work()` also needs to be declared with `async def` for us to be
2525

2626
For this example, let's simulate that by making `do_work()` wait there for 1 second:
2727

28-
{* docs_src/tutorial/first_steps/tutorial001.py ln[4:11] hl[4:5] *}
28+
{* docs_src/tutorial/first_steps/tutorial001_py39.py ln[4:11] hl[4:5] *}
2929

3030
## Run the Main Function
3131

3232
As `main()` is an `async` function, we can't call it directly because we can't `await` it. Instead, we call it with `anyio.run()`:
3333

34-
{* docs_src/tutorial/first_steps/tutorial001.py hl[1,14] *}
34+
{* docs_src/tutorial/first_steps/tutorial001_py39.py hl[1,14] *}
3535

3636
`anyio.run()` will do everything necessary to call `main()`, handling all the `await` parts, and waiting there until it finishes.
3737

0 commit comments

Comments
 (0)