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:
Seth Yastrov
2019-03-28 21:13:02 +01:00
committed by Maxim Kurnikov
parent 9288c34648
commit 71fb0432f3
7 changed files with 87 additions and 14 deletions

View File

@@ -21,7 +21,7 @@ from django.db import models
class MyModel(models.Model):
authors = models.Manager[MyModel]()
reveal_type(MyModel.authors) # E: Revealed type is 'django.db.models.manager.Manager[main.MyModel]'
reveal_type(MyModel.objects) # E: Revealed type is 'Any'
MyModel.objects # E: "Type[MyModel]" has no attribute "objects"
[out]
[CASE test_model_objects_attribute_present_in_case_of_model_cls_passed_as_generic_parameter]