Skip to content

Commit

Permalink
fixing ci
Browse files Browse the repository at this point in the history
  • Loading branch information
waketzheng committed Jan 24, 2025
1 parent f3d648e commit b23078d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 51 deletions.
33 changes: 1 addition & 32 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ bandit = "*"
black = "*"
codespell = "*"
# Test tools
coveralls = "*"
pytest = "*"
pytest-xdist = "*"
pytest-cov = "*"
Expand Down
36 changes: 18 additions & 18 deletions tortoise/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections.abc import Awaitable, Callable, Generator, Iterable
from copy import copy, deepcopy
from functools import partial
from typing import Any, Optional, Type, TypedDict, TypeVar, Union, cast
from typing import Any, Optional, TypedDict, TypeVar, Union, cast

from pypika_tortoise import Order, Query, Table
from pypika_tortoise.terms import Term
Expand Down Expand Up @@ -94,7 +94,7 @@ def _fk_setter(


def _fk_getter(
self: "Model", _key: str, ftype: "Type[Model]", relation_field: str, to_field: str
self: "Model", _key: str, ftype: "type[Model]", relation_field: str, to_field: str
) -> Awaitable:
try:
return getattr(self, _key)
Expand All @@ -106,7 +106,7 @@ def _fk_getter(


def _rfk_getter(
self: "Model", _key: str, ftype: "Type[Model]", frelfield: str, from_field: str
self: "Model", _key: str, ftype: "type[Model]", frelfield: str, from_field: str
) -> ReverseRelation:
val = getattr(self, _key, None)
if val is None:
Expand All @@ -116,7 +116,7 @@ def _rfk_getter(


def _ro2o_getter(
self: "Model", _key: str, ftype: "Type[Model]", frelfield: str, from_field: str
self: "Model", _key: str, ftype: "type[Model]", frelfield: str, from_field: str
) -> "QuerySetSingle[Optional[Model]]":
if hasattr(self, _key):
return getattr(self, _key)
Expand All @@ -136,7 +136,7 @@ def _m2m_getter(
return val


def _get_comments(cls: "Type[Model]") -> dict[str, str]:
def _get_comments(cls: "type[Model]") -> dict[str, str]:
"""
Get comments exactly before attributes
Expand Down Expand Up @@ -237,7 +237,7 @@ def __init__(self, meta: "Model.Meta") -> None:
self.basetable: Table = Table("")
self.pk_attr: str = getattr(meta, "pk_attr", "")
self.generated_db_fields: tuple[str, ...] = None # type: ignore
self._model: Type["Model"] = None # type: ignore
self._model: type["Model"] = None # type: ignore
self.table_description: str = getattr(meta, "table_description", "")
self.pk: Field = None # type: ignore
self.db_pk_column: str = ""
Expand Down Expand Up @@ -474,7 +474,7 @@ def _generate_filters(self) -> None:
class ModelMeta(type):
__slots__ = ()

def __new__(cls, name: str, bases: tuple[Type, ...], attrs: dict[str, Any]) -> "ModelMeta":
def __new__(cls, name: str, bases: tuple[type, ...], attrs: dict[str, Any]) -> "ModelMeta":
fields_db_projection: dict[str, str] = {}
meta_class: "Model.Meta" = attrs.get("Meta", type("Meta", (), {}))
pk_attr: str = "id"
Expand Down Expand Up @@ -528,7 +528,7 @@ def __new__(cls, name: str, bases: tuple[Type, ...], attrs: dict[str, Any]) -> "
return new_class

@classmethod
def _search_for_field_attributes(cls, base: Type, attrs: dict) -> None:
def _search_for_field_attributes(cls, base: type, attrs: dict) -> None:
"""
Searching for class attributes of type fields.Field
in the given class.
Expand Down Expand Up @@ -666,7 +666,7 @@ def build_meta(
meta.abstract = True
return meta

def __getitem__(cls: Type[MODEL], key: Any) -> QuerySetSingle[MODEL]: # type: ignore
def __getitem__(cls: type[MODEL], key: Any) -> QuerySetSingle[MODEL]: # type: ignore
return cls._getbypk(key) # type: ignore


Expand All @@ -677,7 +677,7 @@ class Model(metaclass=ModelMeta):

# I don' like this here, but it makes auto completion and static analysis much happier
_meta = MetaInfo(None) # type: ignore
_listeners: dict[Signals, dict[Type[MODEL], list[Callable]]] = { # type: ignore
_listeners: dict[Signals, dict[type[MODEL], list[Callable]]] = { # type: ignore
Signals.pre_save: {},
Signals.post_save: {},
Signals.pre_delete: {},
Expand Down Expand Up @@ -749,7 +749,7 @@ def _set_kwargs(self, kwargs: dict) -> set[str]:
return passed_fields

@classmethod
def _init_from_db(cls: Type[MODEL], **kwargs: Any) -> MODEL:
def _init_from_db(cls: type[MODEL], **kwargs: Any) -> MODEL:
self = cls.__new__(cls)
self._partial = False
self._saved_in_db = True
Expand Down Expand Up @@ -852,7 +852,7 @@ def _validate_relation_type(cls, field_key: str, value: Optional["Model"]) -> No
)

@classmethod
async def _getbypk(cls: Type[MODEL], key: Any) -> MODEL:
async def _getbypk(cls: type[MODEL], key: Any) -> MODEL:
try:
return await cls.get(pk=key)
except (DoesNotExist, ValueError):
Expand Down Expand Up @@ -1153,7 +1153,7 @@ def select_for_update(

@classmethod
async def update_or_create(
cls: Type[MODEL],
cls: type[MODEL],
defaults: Optional[dict] = None,
using_db: Optional[BaseDBAsyncClient] = None,
**kwargs: Any,
Expand All @@ -1177,7 +1177,7 @@ async def update_or_create(

@classmethod
async def create(
cls: Type[MODEL], using_db: Optional[BaseDBAsyncClient] = None, **kwargs: Any
cls: type[MODEL], using_db: Optional[BaseDBAsyncClient] = None, **kwargs: Any
) -> MODEL:
"""
Create a record in the DB and returns the object.
Expand All @@ -1204,7 +1204,7 @@ async def create(

@classmethod
def bulk_update(
cls: Type[MODEL],
cls: type[MODEL],
objects: Iterable[MODEL],
fields: Iterable[str],
batch_size: Optional[int] = None,
Expand Down Expand Up @@ -1234,7 +1234,7 @@ def bulk_update(

@classmethod
async def in_bulk(
cls: Type[MODEL],
cls: type[MODEL],
id_list: Iterable[Union[str, int]],
field_name: str = "pk",
using_db: Optional[BaseDBAsyncClient] = None,
Expand All @@ -1251,7 +1251,7 @@ async def in_bulk(

@classmethod
def bulk_create(
cls: Type[MODEL],
cls: type[MODEL],
objects: Iterable[MODEL],
batch_size: Optional[int] = None,
ignore_conflicts: bool = False,
Expand Down Expand Up @@ -1394,7 +1394,7 @@ def raw(cls, sql: str, using_db: Optional[BaseDBAsyncClient] = None) -> "RawSQLQ

@classmethod
def exists(
cls: Type[MODEL], *args: Q, using_db: Optional[BaseDBAsyncClient] = None, **kwargs: Any
cls: type[MODEL], *args: Q, using_db: Optional[BaseDBAsyncClient] = None, **kwargs: Any
) -> ExistsQuery:
"""
Return True/False whether record exists with the provided filter parameters.
Expand Down

0 comments on commit b23078d

Please sign in to comment.