add support for OneToOneField, more stubs

This commit is contained in:
Maxim Kurnikov
2018-11-13 17:43:21 +03:00
parent 155dc4e049
commit dc4f606f63
9 changed files with 97 additions and 238 deletions

View File

@@ -7,6 +7,10 @@ from .fields import (AutoField as AutoField,
Field as Field,
SlugField as SlugField,
TextField as TextField)
from .fields.related import (ForeignKey as ForeignKey)
from .deletion import CASCADE as CASCADE
from .fields.related import (ForeignKey as ForeignKey,
OneToOneField as OneToOneField)
from .deletion import (CASCADE as CASCADE,
SET_DEFAULT as SET_DEFAULT,
SET_NULL as SET_NULL,
DO_NOTHING as DO_NOTHING)
from .query import QuerySet as QuerySet

View File

@@ -1,6 +1,16 @@
from typing import Any
class ModelBase(type):
pass
class Model(metaclass=ModelBase):
pass
class DoesNotExist(Exception):
pass
def __init__(self, **kwargs) -> None: ...
def delete(self,
using: Any = ...,
keep_parents: bool = ...) -> None: ...

View File

@@ -1,2 +1,7 @@
def CASCADE(collector, field, sub_objs, using):
...
def CASCADE(collector, field, sub_objs, using): ...
def SET_NULL(collector, field, sub_objs, using): ...
def SET_DEFAULT(collector, field, sub_objs, using): ...
def DO_NOTHING(collector, field, sub_objs, using): ...

View File

@@ -10,5 +10,15 @@ class ForeignKey(Field, Generic[_T]):
def __init__(self,
to: Union[Type[_T], str],
on_delete: Any,
related_name: str = ...,
**kwargs): ...
def __get__(self, instance, owner) -> _T: ...
class OneToOneField(Field, Generic[_T]):
def __init__(self,
to: Union[Type[_T], str],
on_delete: Any,
related_name: str = ...,
**kwargs): ...
def __get__(self, instance, owner) -> _T: ...