Source code for marsha.stubs

"""Stubs for the whole project to be used for typing annotations."""

# pylint: disable=pointless-statement,missing-docstring,unused-argument,invalid-name

from typing import Any, Generic, Iterable, Optional, Tuple, Type, TypeVar

from django.db.models import Model


T = TypeVar("T")
Typing = Any


[docs]class ReverseFKType(Generic[T]): """Stub to represent the related field of a django ``ForeignKey``/``OneToOneField``."""
[docs] def add(self, *objs: T, bulk: Optional[bool] = True) -> None: ...
[docs] def remove(self, *objs: T, bulk: Optional[bool] = True) -> None: ...
[docs] def clear(self, bulk: bool = True) -> None: ...
[docs] def set( self, objs: Iterable[T], bulk: Optional[bool] = True, clear: Optional[bool] = False, ) -> None: ...
[docs] def create(self, **kwargs: Any) -> T: ...
[docs] def get_or_create(self, **kwargs: Any) -> Tuple[T, bool]: ...
[docs] def update_or_create(self, **kwargs: Any) -> Tuple[T, bool]: ...
ReverseO2O = ReverseFKType
[docs]class M2MType(Generic[T]): """Stub to represent both sides of a django ``ManyToManyField``.""" through: Type[Model]
[docs] def add(self, *objs: T) -> None: ...
[docs] def remove(self, *objs: T) -> None: ...
[docs] def clear(self) -> None: ...
[docs] def set(self, objs: Iterable[T], clear: Optional[bool] = False) -> None: ...
[docs] def create(self, **kwargs: Any) -> T: ...
[docs] def get_or_create(self, **kwargs: Any) -> Tuple[T, bool]: ...
[docs] def update_or_create(self, **kwargs: Any) -> Tuple[T, bool]: ...
UniqueTogether = Iterable[Iterable[str]] TupleOfStr = Tuple[str, ...]