By declaring return type as -> Callable[[_C], _C], Mypy can infer that
the decorated function has also the same arguments and return type as
the original.
View functions are constrained to return HttpResponseBase (or any
subclass of it).
Also added typecheck test coverage to most of the cases.
* Updated gitpython dependency to fix error:
ModuleNotFoundError: No module named 'gitdb.utils.compat'
* Updated Django repository git refs because old 3.0.x commit hash gave error:
stderr: 'fatal: reference is not a tree: 6cb30414bc0f83b49afc4cae76d4af5656effe9a'
* Newer Django version also needs new ignores.
* Added missing `follow: bool` argument to Client request methods.
* Annotated return types as `HttpResponse` instead of `Any`.
* Made `Client` class inherit from `RequestFactory`, as it does in Django.
* Changed `json()` return type to Any, as it can also be a list.
Wrt (2), these return types were reverted from `HttpResponse` to `Any`
in commit 287c64d6fb. But I suspect that
was simply to silence mypy warnings about "incompatible with supertype
RequestFactory", not because there were any issues with the annotation.
Note that `Client.request()` monkey-patches the `HttpResponse` object
with some additional attributes. Those attributes were already annotated
before, I reordered and added additional comments to make it clear where
they come from.
* remove mention of mypy newsemanal to prepare for 0.730
* make typecheck_tests CI really work
* fix lints
* fix intentional error
* merge stderr in stdout to preserve order
Co-authored-by: Daniel Hahler <github@thequod.de>
* WIP: fix scripts/typecheck_tests.py
Exit non-zero if it fails to run.
Currently it fails on CI, but goes unnoticed:
https://travis-ci.com/typeddjango/django-stubs/jobs/235296115
* exit on unexpected rc, and output on stderr
* Fix
* scripts/mypy.ini: django_settings_module=scripts.django_tests_settings
* 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.
* Support returning the correct values for the different QuerySet methods when using .values() and .values_list().
* Fix slicing on QuerySet. Fix django queries test, and remove some ignored errors that are no longer needed.
* Remove accidental change in RawQuerySet.
* Readded some still-necessary ignores to aggregation django test.
* Add more tests of first/last/earliest/last/__getitem__, per mkurnikov's comments.
- Fix .iterator()
* Re-add Iterator as base-class of QuerySet.
* Make QuerySet a Collection.
* - Fix return type for QuerySet.select_for_update().
- Use correct return type for QuerySet.dates() / QuerySet.datetimes().
- Use correct type params in return type for QuerySet.__and__ / QuerySet.__or__
- Re-add Sized as base class for QuerySet.
- Add test of .all() for all _Row types.
- Add test of .get() for all _Row types.
- Remove some redundant QuerySet method tests.
* Automatically fill in second type parameter for QuerySet.
... if second parameter is omitted.
* Fix bug where models with a class variable using a manager defined would interfere with other managers.
- Fill in the type argument for that particular instance of the manager, rather than modifying the bases of the Manager type.
- Instantiate a new Instance from determine_proper_manager_type so The code doesn't crash under mypy-mypyc.
* Use helpers.reparametrize_instance per review comment.
* Updated ignored errors in Django test for get_objects_or_404.
- For some reason, `Manager[nothing]` is now removed from expected types.
However, I think this makes sense anyway, as Manager is a subclass of QuerySet.