Commit Graph

20 Commits

Author SHA1 Message Date
sobolevn
372b1340a0 Version django-stubs-ext@0.3.1 release 2021-09-07 22:08:49 +03:00
Eero Ruohola
6424e33a74 Fix BaseModelForm not working with generic type parameter (#705)
Resolves: https://github.com/typeddjango/django-stubs/issues/703
2021-09-07 22:07:22 +03:00
Eero Ruohola
b6d3373c34 Add typing-extension as a direct dependency of django-stubs-ext (#707)
Needed, because `django-stubs-ext` generally has to specified as a
production dependency (to use the monkey patching). `django-stubs` does
have `typing-extensions` as a dependency, but it is often used only as a
dev dependency as it has not runtime functionality.

Resolves: https://github.com/typeddjango/django-stubs/issues/702
2021-09-07 12:01:21 +03:00
sobolevn
a0f893ea3d Version django-stubs-ext@0.3.0 release 2021-09-04 11:30:30 +03:00
PIG208
a6a81797d3 Add py.typed to package distribution of django_stubs_ext. (#694) 2021-08-15 17:52:44 +03:00
Seth Yastrov
cfd69c0acc QuerySet.annotate improvements (#398)
* QuerySet.annotate returns self-type. Attribute access falls back to Any.

- QuerySets that have an annotated model do not report errors during .filter() when called with invalid fields.
- QuerySets that have an annotated model return ordinary dict rather than TypedDict for .values()
- QuerySets that have an annotated model return Any rather than typed Tuple for .values_list()

* Fix .annotate so it reuses existing annotated types. Fixes error in typechecking Django testsuite.

* Fix self-typecheck error

* Fix flake8

* Fix case of .values/.values_list before .annotate.

* Extra ignores for Django 2.2 tests (false positives due to tests assuming QuerySet.first() won't return None)

Fix mypy self-check.

* More tests + more precise typing in case annotate called before values_list.

Cleanup tests.

* Test and fix annotate in combination with values/values_list with no params.

* Remove line that does nothing :)

* Formatting fixes

* Address code review

* Fix quoting in tests after mypy changed things

* Use Final

* Use typing_extensions.Final

* Fixes after ValuesQuerySet -> _ValuesQuerySet refactor. Still not passing tests yet.

* Fix inheritance of _ValuesQuerySet and remove unneeded type ignores.

This allows the test
"annotate_values_or_values_list_before_or_after_annotate_broadens_type"
to pass.

* Make it possible to annotate user code with "annotated models", using PEP 583 Annotated type.

* Add docs

* Make QuerySet[_T] an external alias to _QuerySet[_T, _T].

This currently has the drawback that error messages display the internal type _QuerySet, with both type arguments.

See also discussion on #661 and #608.

Fixes #635: QuerySet methods on Managers (like .all()) now return QuerySets rather than Managers.

Address code review by @sobolevn.

* Support passing TypedDicts to WithAnnotations

* Add an example of an error to README regarding WithAnnotations + TypedDict.

* Fix runtime behavior of ValuesQuerySet alias (you can't extend Any, for example).

Fix some edge case with from_queryset after QuerySet changed to be an
alias to _QuerySet. Can't make a minimal test case as this only occurred
on a large internal codebase.

* Fix issue when using from_queryset in some cases when having an argument with a type annotation on the QuerySet.

The mypy docstring on anal_type says not to call defer() after it.
2021-07-23 16:15:15 +03:00
Petter Friberg
cc5d363cfa Add end-of-file-fixer hook to pre-commit (#668) 2021-07-12 00:48:36 +03:00
Seth Yastrov
f9317c7679 Rename ValuesQuerySet -> _ValuesQuerySet and remove _BaseQuerySet. Ma… (#654)
* Rename ValuesQuerySet -> _ValuesQuerySet and remove _BaseQuerySet. Make a public alias called ValuesQuerySet in django_stubs_ext.

* Update tests
2021-06-28 13:23:00 +03:00
Daniel Hahler
a00563cfa4 [WIP/RFC] Revisit patching of mypy builtins (reveal_{type,locals}) (#615)
* Revisit patching of mypy builtins (reveal_{type,locals})

Fixes https://github.com/typeddjango/django-stubs/issues/609
Reverts ee58b18f15

* Create test_patching.yml

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2021-06-25 16:56:21 +03:00
Chris Beaven
acfe0ce820 Patch detail and list generic view base classes (#642)
Similar to the already patched `FormMixin`, the detail and list generic view classes are also missing __class_getitem__ and choke when you try to use their generics.
2021-06-16 10:32:47 +03:00
Nikita Sobolev
353b790209 Create py.typed 2021-05-21 11:00:24 +03:00
sobolevn
488d17b65c django-stubs-ext@0.2.0 2021-04-14 12:59:57 +03:00
Daniel Hahler
ee58b18f15 WIP: django_stubs_ext: monkeypatch reveal_{type,locals} into builtins (#591)
* WIP: django_stubs_ext: monkeypatch `reveal_{type,locals}` into builtins

Fixes https://github.com/typeddjango/django-stubs/issues/590

* fixup! WIP: django_stubs_ext: monkeypatch `reveal_{type,locals}` into builtins

* fixup! fixup! WIP: django_stubs_ext: monkeypatch `reveal_{type,locals}` into builtins

* Update patch.py

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2021-04-14 12:33:45 +03:00
sobolevn
3cca71a58f Version 1.8.0 release 2021-04-12 13:12:19 +03:00
markedwards
2e9adce5eb Add Field to django_stubs_ext.django_stubs_ext.patch._need_generic (#547) 2020-12-22 10:09:29 +03:00
markedwards
47bd07758b Update django_stubs_ext documentation to reference settings (#548) 2020-12-19 11:50:46 +03:00
sobolevn
16326e999c Fixes CI 2020-11-14 21:18:09 +03:00
sobolevn
517ae648e5 Adds more types to patch 2020-11-14 20:46:32 +03:00
Nikita Sobolev
8a68111ce5 Closes #529 (#530)
* Closes #529

* Fixing CI

* Fixing CI

* new monorepo setup
2020-11-14 20:03:50 +03:00
proxy
0c41d0c6e9 create monkeypatching function for adding get_item dunder (#526)
* run black

* create monkeypatching function for adding get_item dunder

* whoops i forgot the test

* change the name in INSTALLED_APPS to make test pass

* turn the whole thing into a proper package

* move django_stubs_ext to requirements.txt

* also install requirements.txt

* attempt to fix pre-commit

* numerous small code review fixes

* fix dependency issues

* small dependency fixes

* configure proper license file location

* add the rest of the monkeypatching

* use strict mypy

* update contributing with a note monkeypatching generics

* copy release script from parent package
2020-11-11 10:04:13 +03:00