Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/autodeps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: "3.10"
python-version: "3.11"

- name: Bump dependencies
run: |
python -m pip install -U pip pre-commit
python -m pip install -r test-requirements.txt
uv pip compile --universal --python-version=3.10 --upgrade test-requirements.in -o test-requirements.txt
uv pip compile --universal --python-version=3.11 --upgrade test-requirements.in -o test-requirements.txt
uv pip compile --universal --python-version=3.11 --upgrade docs-requirements.in -o docs-requirements.txt
pre-commit autoupdate --jobs 0

Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,18 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.14t', '3.15', '3.15t']
python: ['3.11', '3.12', '3.13', '3.14', '3.14t', '3.15', '3.15t']
arch: ['x86', 'x64']
lsp: ['']
lsp_extract_file: ['']
extra_name: ['']
include:
- python: '3.10'
- python: '3.11'
arch: 'x64'
lsp: 'https://raw.githubusercontent.com/python-trio/trio-ci-assets/master/komodia-based-vpn-setup.zip'
lsp_extract_file: 'komodia-based-vpn-setup.exe'
extra_name: ', with Komodia LSP'
- python: '3.10'
- python: '3.11'
arch: 'x64'
lsp: 'https://www.proxifier.com/download/legacy/ProxifierSetup342.exe'
lsp_extract_file: ''
Expand Down Expand Up @@ -243,7 +243,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['pypy-3.11', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t', '3.15', '3.15t']
python: ['pypy-3.11', '3.11', '3.12', '3.13', '3.14', '3.14t', '3.15', '3.15t']
check_formatting: ['0']
no_test_requirements: ['0']
extra_name: ['']
Expand All @@ -252,7 +252,7 @@ jobs:
check_formatting: '1'
extra_name: ', check formatting'
# separate test run that doesn't install test-requirements.txt
- python: '3.10'
- python: '3.11'
no_test_requirements: '1'
extra_name: ', no test-requirements'
continue-on-error: >-
Expand Down Expand Up @@ -288,7 +288,7 @@ jobs:
if: matrix.check_formatting == '1'
uses: actions/setup-python@v6
with:
python-version: '3.10'
python-version: '3.11'
cache: pip
cache-dependency-path: test-requirements.txt
allow-prereleases: true
Expand Down Expand Up @@ -321,7 +321,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['pypy-3.11', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t', '3.15', '3.15t']
python: ['pypy-3.11', '3.11', '3.12', '3.13', '3.14', '3.14t', '3.15', '3.15t']
continue-on-error: >-
${{
(
Expand Down Expand Up @@ -412,12 +412,10 @@ jobs:
include:
# Cython 2 supports 3.10 and 3.11 and Cython 3 supports all versions we do,
# so test both the lowest and higher version for both
- python: '3.10'
cython: '<3'
- python: '3.11'
cython: '<3'
# TODO: technically we should pin cython versions
- python: '3.10'
- python: '3.11'
cython: '>=3'
- python: '3.15'
cython: '>=3'
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ repos:
name: uv pip-compile test-requirements.in
args: [
"--universal",
"--python-version=3.10",
"--python-version=3.11",
"test-requirements.in",
"-o",
"test-requirements.txt"]
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ demonstration of implementing the "Happy Eyeballs" algorithm in an
older library versus Trio.

**Cool, but will it work on my system?** Probably! As long as you have
some kind of Python 3.10-or-better (CPython or `currently maintained versions of
some kind of Python 3.11-or-better (CPython or `currently maintained versions of
PyPy3 <https://doc.pypy.org/en/latest/faq.html#which-python-versions-does-pypy-implement>`__
are both fine), and are using Linux, macOS, Windows, or FreeBSD, then Trio
will work. Other environments might work too, but those
Expand Down
24 changes: 7 additions & 17 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
from pathlib import Path
from typing import TYPE_CHECKING, cast

if sys.version_info >= (3, 11):
from sphinx.util.inventory import _InventoryItem

from sphinx.util.inventory import _InventoryItem
from sphinx.util.logging import getLogger

if TYPE_CHECKING:
Expand Down Expand Up @@ -274,20 +272,12 @@ def add_mapping(
assert isinstance(inventory, dict)
inventory = cast("Inventory", inventory)

if sys.version_info >= (3, 11):
inventory[f"py:{reftype}"][f"{target}"] = _InventoryItem(
project_name="Python",
project_version=version,
uri=f"https://docs.python.org/{url_version}/library/{library}.html/{obj}",
display_name="-",
)
else:
inventory[f"py:{reftype}"][f"{target}"] = (
"Python",
version,
f"https://docs.python.org/{url_version}/library/{library}.html/{obj}",
"-",
)
inventory[f"py:{reftype}"][f"{target}"] = _InventoryItem(
project_name="Python",
project_version=version,
uri=f"https://docs.python.org/{url_version}/library/{library}.html/{obj}",
display_name="-",
)

# This has been removed in Py3.12, so add a link to the 3.11 version with deprecation warnings.
add_mapping("method", "pathlib", "Path.link_to", "3.11")
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Vital statistics:

* Supported environments: We test on

- Python: 3.10+ (CPython and PyPy)
- Python: 3.11+ (CPython and PyPy)
- Windows, macOS, Linux (glibc and musl), FreeBSD

Other environments might also work; give it a try and see.
Expand Down
39 changes: 0 additions & 39 deletions docs/source/reference-core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -773,45 +773,6 @@ If you want to reraise exceptions, or raise new ones, you can do so, but be awar
exceptions raised in ``except*`` sections will be raised together in a new exception
group.

But what if you can't use Python 3.11, and therefore ``except*``, just yet?
The same exceptiongroup_ library which backports `ExceptionGroup` also lets
you approximate this behavior with exception handler callbacks:

.. code-block:: python

from exceptiongroup import catch

def handle_keyerrors(excgroup):
for exc in excgroup.exceptions:
... # handle each KeyError

def handle_indexerrors(excgroup):
for exc in excgroup.exceptions:
... # handle each IndexError

with catch({
KeyError: handle_keyerrors,
IndexError: handle_indexerrors
}):
async with trio.open_nursery() as nursery:
nursery.start_soon(broken1)
nursery.start_soon(broken2)

The semantics for the handler functions are equal to ``except*`` blocks, except for
setting local variables. If you need to set local variables, you need to declare them
inside the handler function(s) with the ``nonlocal`` keyword:

.. code-block:: python

def handle_keyerrors(excgroup):
nonlocal myflag
myflag = True

myflag = False
with catch({KeyError: handle_keyerrors}):
async with trio.open_nursery() as nursery:
nursery.start_soon(broken1)

.. _handling_exception_groups:

Designing for multiple errors
Expand Down
1 change: 1 addition & 0 deletions newsfragments/3594.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop support for Python 3.10.
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand All @@ -35,7 +34,7 @@ classifiers = [
"Topic :: System :: Networking",
"Typing :: Typed",
]
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
# attrs 19.2.0 adds `eq` option to decorators
# attrs 20.1.0 adds @frozen
Expand All @@ -50,7 +49,6 @@ dependencies = [
# cffi 1.14 fixes memory leak inside ffi.getwinerror()
# cffi is required on Windows, except on PyPy where it is built-in
"cffi>=1.14; os_name == 'nt' and implementation_name != 'pypy'",
"exceptiongroup; python_version < '3.11'",
]
dynamic = ["version"]

Expand Down Expand Up @@ -161,6 +159,7 @@ extend-ignore = [

# conflicts with formatter (ruff recommends these be disabled)
"missing-trailing-comma", # COM812
"non-pep646-unpack" # (UP044) ignoring it for now(See: https://github.com/python-trio/trio/pull/3594#issuecomment-6898086470)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed once jedi supports * unpack operator.

]

[tool.ruff.lint.per-file-ignores]
Expand Down Expand Up @@ -195,7 +194,7 @@ combine-as-imports = true
fixture-parentheses = false

[tool.mypy]
python_version = "3.10"
python_version = "3.11"
files = ["src/trio/", "docs/source/*.py"]

# Be flexible about dependencies that don't have stubs yet (like pytest)
Expand All @@ -222,7 +221,7 @@ disallow_untyped_defs = true
check_untyped_defs = true

[tool.pyright]
pythonVersion = "3.10"
pythonVersion = "3.11"
reportUnnecessaryTypeIgnoreComment = true
typeCheckingMode = "strict"

Expand Down
4 changes: 1 addition & 3 deletions src/trio/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import socket
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Generic, Literal, TypeVar
from typing import TYPE_CHECKING, Generic, Literal, Self, TypeVar

import trio

if TYPE_CHECKING:
from types import TracebackType

from typing_extensions import Self

# both of these introduce circular imports if outside a TYPE_CHECKING guard
from ._socket import SocketType
from .lowlevel import Task
Expand Down
19 changes: 5 additions & 14 deletions src/trio/_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from contextlib import AbstractAsyncContextManager, asynccontextmanager
from functools import wraps
from math import inf
from typing import (
TYPE_CHECKING,
Generic,
)
from typing import TYPE_CHECKING, Generic, ParamSpec, Self

import attrs
from outcome import Error, Value
Expand All @@ -25,14 +22,9 @@
raise_single_exception_from_group,
)

if sys.version_info < (3, 11):
from exceptiongroup import BaseExceptionGroup

if TYPE_CHECKING:
from types import TracebackType

from typing_extensions import ParamSpec, Self

P = ParamSpec("P")
elif "sphinx.ext.autodoc" in sys.modules:
# P needs to exist for Sphinx to parse the type hints successfully.
Expand Down Expand Up @@ -583,11 +575,10 @@ async def context_manager(
except MultipleExceptionError:
# In case user has except* we make it possible for them to handle the
# exceptions.
if sys.version_info >= (3, 11):
eg.add_note(
"Encountered exception during cleanup of generator object, as "
"well as exception in the contextmanager body - unable to unwrap."
)
eg.add_note(
"Encountered exception during cleanup of generator object, as "
"well as exception in the contextmanager body - unable to unwrap."
)

raise eg from None

Expand Down
14 changes: 7 additions & 7 deletions src/trio/_core/_asyncgens.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
import warnings
import weakref
from typing import TYPE_CHECKING, NoReturn, TypeVar
from typing import TYPE_CHECKING, Never, TypeVar

import attrs

Expand All @@ -23,8 +23,8 @@

_P = ParamSpec("_P")

_WEAK_ASYNC_GEN_SET = weakref.WeakSet[AsyncGeneratorType[object, NoReturn]]
_ASYNC_GEN_SET = set[AsyncGeneratorType[object, NoReturn]]
_WEAK_ASYNC_GEN_SET = weakref.WeakSet[AsyncGeneratorType[object, Never]]
_ASYNC_GEN_SET = set[AsyncGeneratorType[object, Never]]
else:
_WEAK_ASYNC_GEN_SET = weakref.WeakSet
_ASYNC_GEN_SET = set
Expand Down Expand Up @@ -66,7 +66,7 @@ class AsyncGenerators:
prev_hooks: sys._asyncgen_hooks = attrs.field(init=False)

def install_hooks(self, runner: _run.Runner) -> None:
def firstiter(agen: AsyncGeneratorType[object, NoReturn]) -> None:
def firstiter(agen: AsyncGeneratorType[object, Never]) -> None:
if hasattr(_run.GLOBAL_RUN_CONTEXT, "task"):
self.alive.add(agen)
else:
Expand All @@ -81,7 +81,7 @@ def firstiter(agen: AsyncGeneratorType[object, NoReturn]) -> None:
self.prev_hooks.firstiter(agen)

def finalize_in_trio_context(
agen: AsyncGeneratorType[object, NoReturn],
agen: AsyncGeneratorType[object, Never],
agen_name: str,
) -> None:
try:
Expand All @@ -99,7 +99,7 @@ def finalize_in_trio_context(
self.trailing_needs_finalize.add(agen)

@_core.enable_ki_protection
def finalizer(agen: AsyncGeneratorType[object, NoReturn]) -> None:
def finalizer(agen: AsyncGeneratorType[object, Never]) -> None:
try:
self.foreign.remove(id(agen))
except KeyError:
Expand Down Expand Up @@ -222,7 +222,7 @@ def close(self) -> None:

async def _finalize_one(
self,
agen: AsyncGeneratorType[object, NoReturn],
agen: AsyncGeneratorType[object, Never],
name: object,
) -> None:
try:
Expand Down
3 changes: 1 addition & 2 deletions src/trio/_core/_entry_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import threading
from collections import deque
from collections.abc import Callable
from typing import TYPE_CHECKING, NoReturn
from typing import TYPE_CHECKING, NoReturn, TypeVarTuple, Unpack

import attrs

Expand All @@ -12,7 +12,6 @@
from ._wakeup_socketpair import WakeupSocketpair

if TYPE_CHECKING:
from typing_extensions import TypeVarTuple, Unpack

PosArgsT = TypeVarTuple("PosArgsT")

Expand Down
Loading
Loading