Skip to content
Draft
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
26 changes: 25 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,39 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: 3.x
cache: pip
cache-dependency-path: pyproject.toml
- uses: actions/cache@v6
with:
path: ~/.cache/pip
key: pip-pyright
- name: Install dependencies
run: pip install -e . pyright
run: pip install --group pyright -e .
- name: Run pyright
run: pyright --ignoreexternal --verifytypes anyio

zuban:
runs-on: ubuntu-latest
needs: changed-files
if: |
${{
(needs.changed-files.outputs.workflow-changed == 'true')
|| (needs.changed-files.outputs.src-changed == 'true')
|| (needs.changed-files.outputs.tests-changed == 'true')
}}
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.x
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: pip install --group zuban -e .
- name: Run zuban
run: zuban check

test:
strategy:
fail-fast: false
Expand Down
9 changes: 0 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ repos:
args: [--fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.3.0
hooks:
- id: mypy
pass_filenames: false
additional_dependencies:
- pytest
- trio >= 0.26

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand Down
19 changes: 16 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ doc = [
"sphinx-autodoc-typehints >= 1.2.0",
"sphinx-tabs >= 3.3.1",
]
pyright = [
"pyright >= 1.1.411",
]
zuban = [
"zuban >= 0.9.1",
]

[tool.setuptools_scm]
version_scheme = "post-release"
Expand Down Expand Up @@ -114,12 +120,13 @@ ignore = [
"tests/test_tempfile.py" = ["ASYNC230"]
"tests/*.py" = ["ASYNC240"]

[tool.mypy]
[tool.zuban]
python_version = "3.14"
strict = true
warn_unreachable = false
disallow_any_generics = false
warn_return_any = false
files = ["src", "tests"]
files = ["src"]

[tool.pytest]
addopts = [
Expand Down Expand Up @@ -187,8 +194,14 @@ depends = []
allowlist_externals = ["pre-commit"]
package = "skip"

[tool.tox.env.zuban]
commands = [["zuban", "check"]]
dependency_groups = ["zuban"]
allowlist_externals = ["zuban"]
package = "skip"

[tool.tox.env.pyright]
deps = ["pyright"]
dependency_groups = ["pyright"]
commands = [["pyright", "--ignoreexternal", "--verifytypes", "anyio"]]

[tool.tox.env.docs]
Expand Down
11 changes: 5 additions & 6 deletions src/anyio/_backends/_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,7 @@ def callback(f: object) -> None:
del self._receive_future
loop.remove_reader(self.__raw_socket)

f: asyncio.Future[None]
f = self._receive_future = asyncio.Future()
loop.add_reader(self.__raw_socket, f.set_result, None)
f.add_done_callback(callback)
Expand All @@ -1433,6 +1434,7 @@ def callback(f: object) -> None:
del self._send_future
loop.remove_writer(self.__raw_socket)

f: asyncio.Future[None]
f = self._send_future = asyncio.Future()
loop.add_writer(self.__raw_socket, f.set_result, None)
f.add_done_callback(callback)
Expand Down Expand Up @@ -2583,7 +2585,7 @@ def create_capacity_limiter(cls, total_tokens: float) -> abc.CapacityLimiter:
return CapacityLimiter(total_tokens)

@classmethod
async def run_sync_in_worker_thread( # type: ignore[return]
async def run_sync_in_worker_thread( # type: ignore[return-value]
cls,
func: Callable[[Unpack[PosArgsT]], T_Retval],
args: tuple[Unpack[PosArgsT]],
Expand Down Expand Up @@ -2779,11 +2781,8 @@ def setup_process_pool_exit_at_shutdown(cls, workers: set[abc.Process]) -> None:
async def connect_tcp(
cls, host: str, port: int, local_address: IPSockAddrType | None = None
) -> abc.SocketStream:
transport, protocol = cast(
tuple[asyncio.Transport, StreamProtocol],
await get_running_loop().create_connection(
StreamProtocol, host, port, local_addr=local_address
),
transport, protocol = await get_running_loop().create_connection(
StreamProtocol, host, port, local_addr=local_address
)
transport.pause_reading()
return SocketStream(transport, protocol)
Expand Down
2 changes: 1 addition & 1 deletion src/anyio/itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def __anext__(self) -> T:


async def _operator_add(x: T, y: T) -> T:
return operator.add(x, y)
return operator.add(x, y) # type: ignore[call-overload]


async def accumulate(
Expand Down
8 changes: 4 additions & 4 deletions src/anyio/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ def pytest_collection_finish(session: pytest.Session) -> None:
marks=[],
)
else: # pytest 7.x
callspec = CallSpec2( # type: ignore[call-arg]
funcargs={},
callspec = CallSpec2(
funcargs={}, # type: ignore[call-arg]
params={"anyio_backend": backend},
indices={"anyio_backend": param_index},
arg2scope={"anyio_backend": Scope.Module},
idlist=[backend],
arg2scope={"anyio_backend": Scope.Module}, # type: ignore[call-arg]
idlist=[backend], # type: ignore[call-arg]
marks=[],
)

Expand Down
2 changes: 1 addition & 1 deletion src/anyio/to_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
_default_process_limiter: RunVar[CapacityLimiter] = RunVar("_default_process_limiter")


async def run_sync( # type: ignore[return]
async def run_sync( # type: ignore[return-value]
func: Callable[[Unpack[PosArgsT]], T_Retval],
*args: Unpack[PosArgsT],
cancellable: bool = False,
Expand Down
Loading