Skip to content

Commit

Permalink
add missing type annotations for a few methods & props on .m. and .qu…
Browse files Browse the repository at this point in the history
…ery.
  • Loading branch information
brondsem committed Aug 15, 2024
1 parent 5be2970 commit 59689c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 8 additions & 4 deletions ming/metadata.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ from bson import ObjectId
from datetime import datetime
from typing import Generic, TypeVar, Any, Optional, overload, List, Dict, Type, Union, Mapping, type_check_only
from pymongo.results import UpdateResult, DeleteResult
from pymongo.command_cursor import CommandCursor

import bson
from ming.base import Cursor

from . import schema
from .base import Object
from .session import Session


AnyType = TypeVar('AnyType')
Expand Down Expand Up @@ -181,6 +183,9 @@ M = TypeVar('M')
MongoFilter = dict
SaveResult = Union[ObjectId, Any]
class _ClassManager(Generic[M]):
session: Session
collection_name: str

# proxies these from Session
def get(self, **kwargs) -> Optional[M]: ...
def find(self, filter: MongoFilter = None, *args, **kwargs) -> Cursor[M]: ...
Expand All @@ -196,13 +201,12 @@ class _ClassManager(Generic[M]):
def find_one_and_update(self, **kwargs) -> M: ...
def find_one_and_replace(self, **kwargs) -> M: ...
def find_one_and_delete(self, **kwargs) -> M: ...
def aggregate(self, pipeline: list, **kwargs) -> CommandCursor: ...
def distinct(self, key: str, filter: MongoFilter | None = None, **kwargs) -> list: ...
"""
def group(self) -> int: ...
def ensure_indexes(self) -> int: ...
def index_information(self) -> int: ...
def drop_indexes(self) -> int: ...
def aggregate(self) -> int: ...
def distinct(self) -> int: ...
"""

class _InstanceManager:
Expand All @@ -219,4 +223,4 @@ class _InstanceManager:
class Manager(_ClassManager[M], _InstanceManager): ...


def __getattr__(name) -> Any: ... # marks file as incomplete
def __getattr__(name) -> Any: ... # marks file as incomplete
9 changes: 4 additions & 5 deletions ming/odm/mapper.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import type_check_only, TypeVar, Generic, Optional, Union, Any, Dict, overload

from bson import ObjectId
from pymongo.command_cursor import CommandCursor

from ming.base import Cursor

M = TypeVar('M')
Expand All @@ -18,11 +20,8 @@ class _ClassQuery(Generic[M]):
def find_one_and_replace(self, **kwargs) -> M: ...
def find_one_and_delete(self, **kwargs) -> M: ...
def update_partial(self, filter: MongoFilter, fields: dict, **kwargs) -> ChangeResult: ...
"""
def group(self) -> int: ...
def distinct(self) -> int: ...
def aggregate(self) -> int: ...
"""
def aggregate(self, pipeline: list, **kwargs) -> CommandCursor: ...
def distinct(self, key: str, filter: MongoFilter | None = None, **kwargs) -> list: ...

class _InstQuery(object):
# proxied from session:
Expand Down

0 comments on commit 59689c8

Please sign in to comment.