mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-16 08:47:49 +08:00
52/model subtypes dont typecheck (#55)
* Fix problem where Model instancess are not considered subtypes of each other due to fallback_to_any = True. Fixes #52. - Added a stub for __getstate__ to Model. - Added a stub for clean() to Model. - Correct arg type for sort_dependencies so they are covariant (Iterable rather than List). Test ignores: - Added some test ignores in cases where a model inherits from 2 different base models. - Added some test ignores for cases that MyPy flags as errors due to variable redefinitions or imports that are incompatible types. * Address review comment.
This commit is contained in:
committed by
Maxim Kurnikov
parent
9288c34648
commit
71fb0432f3
@@ -1,5 +1,4 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union, Iterable
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
from django.db.models.base import Model
|
||||
@@ -33,5 +32,5 @@ def serialize(
|
||||
) -> Optional[Union[bytes, str]]: ...
|
||||
def deserialize(format: str, stream_or_string: Any, **options: Any) -> Union[Iterator[Any], Deserializer]: ...
|
||||
def sort_dependencies(
|
||||
app_list: Union[List[Tuple[AppConfig, None]], List[Tuple[str, List[Type[Model]]]]]
|
||||
app_list: Union[Iterable[Tuple[AppConfig, None]], Iterable[Tuple[str, Iterable[Type[Model]]]]]
|
||||
) -> List[Type[Model]]: ...
|
||||
|
||||
Reference in New Issue
Block a user