Skip to content

Commit

Permalink
typing improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
brondsem committed Sep 9, 2022
1 parent 3853256 commit 2adbf3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ming/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Union
import urllib
from pymongo import MongoClient
from pymongo.database import Database
from pymongo.errors import ConnectionFailure, InvalidURI
from pymongo.uri_parser import parse_uri

Expand Down Expand Up @@ -174,11 +175,11 @@ def __getattr__(self, name):
return getattr(self.db, name)

@property
def conn(self):
def conn(self) -> Conn:
return self.bind.conn

@property
def db(self):
def db(self) -> Database:
"""This is the database on MongoDB.
Accessing this property returns the pymongo db,
Expand Down
3 changes: 3 additions & 0 deletions ming/odm/property.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# re-use all the Field type handling
from collections.abc import Iterable
from typing import overload, Union, Type, Any, TypeVar, TypeAlias

from bson import ObjectId
Expand All @@ -21,6 +22,8 @@ class RelationProperty:
def __new__(self, related: str, via: str=None, fetch=True) -> Any:...
@overload
def __new__(self, related: Type[MC], via: str=None, fetch=True) -> MC:...
@overload
def __new__(self, related: Type[MC], via: str=None, fetch=True) -> Iterable[MC]:...


def __getattr__(name) -> Any: ... # marks file as incomplete

0 comments on commit 2adbf3a

Please sign in to comment.