diff --git a/ming/odm/mapper.pyi b/ming/odm/mapper.pyi index 8598cf8..6460c21 100644 --- a/ming/odm/mapper.pyi +++ b/ming/odm/mapper.pyi @@ -1,4 +1,4 @@ -from typing import type_check_only, TypeVar, Generic, Optional, Union, Any, Dict +from typing import type_check_only, TypeVar, Generic, Optional, Union, Any, Dict, overload from bson import ObjectId from ming.base import Cursor @@ -12,10 +12,9 @@ class _ClassQuery(Generic[M]): def get(self, _id: Union[ObjectId|Any] = None, **kwargs) -> Optional[M]: ... def find(self, filter: MongoFilter = None, *args, **kwargs) -> Cursor[M]: ... def find_by(self, filter: MongoFilter = None, *args, **kwargs) -> Cursor[M]: ... - def remove(self, spec_or_id: Union[MongoFilter, ObjectId], **kwargs) -> ChangeResult: ... + def remove(self, spec_or_id: Union[MongoFilter, ObjectId] = None, **kwargs) -> ChangeResult: ... def count(self) -> int: ... def find_and_modify(self, **kwargs) -> M: ... - def update(self, spec: MongoFilter, fields: dict, **kwargs) -> ChangeResult: ... """ def group(self) -> int: ... def distinct(self) -> int: ... @@ -29,10 +28,15 @@ class _InstQuery(object): def update_if_not_modified(self, obj, fields, upsert=False) -> bool: ... def delete(self) -> ChangeResult: ... - def update(self, fields, **kwargs) -> ChangeResult: ... @type_check_only -class Query(_ClassQuery[M], _InstQuery): ... +class Query(_ClassQuery[M], _InstQuery): + + @overload # from _ClassQuery + def update(self, spec: MongoFilter, fields: dict, **kwargs) -> ChangeResult: ... + + @overload # from _InstQuery + def update(self, fields, **kwargs) -> ChangeResult: ... def __getattr__(name) -> Any: ... # marks file as incomplete \ No newline at end of file diff --git a/ming/odm/property.pyi b/ming/odm/property.pyi index f140054..a79b796 100644 --- a/ming/odm/property.pyi +++ b/ming/odm/property.pyi @@ -12,15 +12,15 @@ MC = TypeVar('MC', bound=MappedClass) class ForeignIdProperty: @overload - def __new__(self, related: Type, uselist=False, allow_none=False, *args, **kwargs) -> ObjectId: ... + def __new__(self, related: Type[MC], uselist=False, allow_none=False, *args, **kwargs) -> ObjectId: ... @overload - def __new__(self, related: TypeAlias, uselist=False, allow_none=False, *args, **kwargs) -> ObjectId: ... + def __new__(self, related: str, uselist=False, allow_none=False, *args, **kwargs) -> ObjectId: ... class RelationProperty: @overload - def __new__(self, related: TypeAlias, via: str=None, fetch=True) -> Any:... + def __new__(self, related: str, via: str=None, fetch=True) -> Any:... @overload - def __new__(self, related: MC, via: str=None, fetch=True) -> MC:... + def __new__(self, related: Type[MC], via: str=None, fetch=True) -> MC:... def __getattr__(name) -> Any: ... # marks file as incomplete \ No newline at end of file