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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ jobs:
DEST_SANIC: examples/sanic
PYTHONDEVMODE: 1
PYTEST_ARGS: "-n auto --cov=tortoise --cov-append --cov-branch --tb=native -q"
- name: Test No typing-extensions
if: matrix.tortoise-orm == 'py3.14'
run: |
uv pip uninstall typing-extensions
uv run --no-sync python examples/basic.py
- name: Upload Coverage
run: |
uvx coveralls --service=github
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Changelog
0.26.0 (unreleased)
-------------------

Fixed
^^^^^
- Fix 'Self' in python standard library typing.py, but tortoise/model.py required it in 'typing_extensions' (#2051)

0.25
====

Expand Down
10 changes: 8 additions & 2 deletions tortoise/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import asyncio
import inspect
import re
import sys
from collections.abc import Awaitable, Callable, Generator, Iterable
from copy import copy, deepcopy
from functools import partial
from typing import Any, TypedDict, TypeVar, cast
from typing import TYPE_CHECKING, Any, TypedDict, TypeVar, cast

from pypika_tortoise import Order, Query, Table
from pypika_tortoise.terms import Term
from typing_extensions import Self

from tortoise import connections
from tortoise.backends.base.client import BaseDBAsyncClient
Expand Down Expand Up @@ -54,6 +54,12 @@
from tortoise.signals import Signals
from tortoise.transactions import in_transaction

if TYPE_CHECKING:
if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

MODEL = TypeVar("MODEL", bound="Model")
EMPTY = object()

Expand Down
3 changes: 1 addition & 2 deletions tortoise/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
from collections import defaultdict
from collections.abc import AsyncIterator, Callable, Collection, Generator, Iterable
from copy import copy
from typing import TYPE_CHECKING, Any, Generic, Optional, TypeVar, cast, overload
from typing import TYPE_CHECKING, Any, Generic, Literal, Optional, Protocol, TypeVar, cast, overload

from pypika_tortoise import JoinType, Order, Table
from pypika_tortoise.analytics import Count
from pypika_tortoise.functions import Cast
from pypika_tortoise.queries import QueryBuilder
from pypika_tortoise.terms import Case, Field, Star, Term, ValueWrapper
from typing_extensions import Literal, Protocol

from tortoise.backends.base.client import BaseDBAsyncClient, Capabilities
from tortoise.exceptions import (
Expand Down
Loading