* Add generic monkeypatching for `FileProxyMixin`.
This fixes `TypeError: 'type' object is not subscriptable` for
`django.core.files.File` and `django.core.files.base.ContentFile`.
* Add generic monkeypatching for `ForeignKey`.
This matches the change coming in Django 4.1.
See https://github.com/django/django/pull/15571
* Fix stubs related to `(Async)RequestFactory` and `(Async)Client`
* Revert incorrect removal.
* Allow set as `unique_together`, use shared type alias.
* Revert `Q.__init__` to use only `*args, **kwargs` to remove false-positive with `Q(**{...})`
* Add abstract methods to `HttpResponseBase` to create common interface.
* Remove monkey-patched attributes from `HttpResponseBase` subclasses.
* Add QueryDict mutability checks (+ plugin support)
* Fix lint
* Return back GenericForeignKey to `Options.get_fields`
* Minor fixup
* Make plugin code typecheck with `--warn-unreachable`, minor performance increase.
* Better types for `{unique, index}_together` and Options.
* Fix odd type of `URLResolver.urlconf_name` which isn't a str actually.
* Better types for field migration operations.
* Revert form.files to `MultiValueDict[str, UploadedFile]`
* Compatibility fix (#916)
* Do not assume that `Annotated` is always related to django-stubs (fixes#893)
* Restrict `FormView.get_form` return type to `_FormT` (class type argument). Now it is resolved to `form_class` argument if present, but also errors if it is not subclass of _FormT
* Fix CI (make test runnable on 3.8)
* Fix CI (make test runnable on 3.8 _again_)
* Make module declaration precise.
* Make settings match real file.
* Replace `include` with import.
* Make types more specific.
* Replace `WSGIRequest` with `HttpRequest` where possible.
* Replace all `OrderedDict` occurrences with plain `Dict` (it is not used in Django 3.2 and later)
* Add fake datastructures for convenience: _PropertyDescriptor and _ListOrTuple now can live here. Added _IndexableCollection (often useful as alias for 'sequence or queryset')
* Actualize other datastructures.
* Rework MultiValueDict to reflect the fact that some methods can return empty list instead of value.
* Deprecate SafeText in favor of SafeString.
* Minor improvements to utils
* Disallow using str in TimeFormat and DateFormat, drop removed fmt `B`
* Do not let classproperty expect classmethod, make return value covariant.
* Sync with real file.
* Improve types for timezone.
* Sync deprecated, new and removed features in translation utils.
* Drop removed files, sync huge deprecations.
* Fix incompatible decorators (properties, contextmanagers)
* Rework pagination.
* Sync validators with real code. Add _ValidatorCallable for any external use (field validation etc.)
* Add shared type definitions (for fields of both forms and models). Actualize model fields. Mark keyword-only args explicitly in stubs (where code uses **kwargs). Disallow bytes for verbose_name.
* Make all checks return Sequence[CheckMessage] or subclass to be covariant.
* Add bidirectional references between backend.base and other files. Replace some Any's with specific types.
* Actualize db.migrations: remove removed methods, replace "None" annotations in wrong places, improve some wrong annotations.
* Actualize db.utils to match real file.
* Replace FileResponse and TemplateResponse with HttpResponse(Base) where needed: at least HttpResponseNotModified/HttpResponseRedirect can be returned instead of it, so annotation was wrong.
* Replace Any in forms where possible. Actualize class bases and method arguments.
* Improve typing of serializers.
* Actualize views, rename variable bound to Model to _M for consistency.
* Make types of file-related code consistent. Disallow using bytes as path, because many methods expect str-only paths. Make File inherit from IO[AnyStr] instead of IO[Any]: it makes impossible to instantiate file of union type, but allows precise types for some methods.
* Minor improvements: stop using None as annotation in wrong places, replace obvious Any's with precise types, actualize methods (missing/renamed/signature changed).
* Allow less specific containers, replace Any's with specific types.
* Improve types for requests and responses.
* Use AbstractBaseUser instead of User in auth.
* Use broader type for permission_required
* Use wider container types. Add 'type: ignore' to avoid issues with mypy.stubtest.
* Disallow using backend class as argument (it is passed to import_string).
* Add required methods to PasseordValidator.
* Allow using Path instance as argument.
* Actualize methods.
* Add 'type: ignore' to avoid issues with mypy.stubtest.
* Replace Any's with specific types and BaseForm with ModelForm.
* Actualize contrib.postgres
* Remove render_to_response, add 'get_absolute_url' to corresponding protocol.
* Actualize signers.
* Use precise types for handlers. Disallow str as stream type for LimitedStream.
* Exact types for ValidationError
* Replace wrong used Union with Sequence.
* Actualize static handlers.
* More specific types for admin. Fixes#874.
* Improve types and replace 'Tags' with str (it isn't Enum, so annotation was wrong).
* Replace Any with specific types, actualize signatures.
* Add async variants of handlers and clients. Use fake class to distinguish between request types in RequestFactory and AsyncRequestFactory.
* Fix signature, minor improvements.
* Actualize signatures and class names, replace Any with more specific types.
* Fix signature.
* Add some missing methods to Collector
* Combinable rarely returns Self type: almost always it's CombinedExpression.
* No Random in source anymore.
* Drop removed SimpleCol.
* Replace _OutputField with Field: nothing in docs about strings.
* Introduce reusable types, add missing methods. Remove strange types (probably created by stubgen). Remove RawQuery from Compiler: it obviously doesn't work with RawQuery.
* Use literal constants.
* Actualize base classes.
* Callable is not accepted by get_field.
* Add precise types.
* Use property and broader containers where possible. Add missing methods.
* Actualize indexes.
* More specific types for signals.
* Fix signatures, drop missing methods.
* Actualize window functions to match source.
* Actualize text functions, add missing methods, use type aliases for consistency.
* Add missing property decorators, methods and attributes. Use type aliases. Remove absent YearComparisonLookup and any SafeText references (they aren't related to lookups at all).
* Use bound TypeVar, mark all BuiltinLookup descendants as generic explicitly. Remove strange Union from Lookup.__init__
* Apply type alias, fix base class and argument name.
* Actualize BaseExpression methods.
* Fix imports.
* Add missing class and fix incompatible bases.
* Use same types in __init__ and attribute.
* OrderBy accepts F or Expression.
* Non-expressions are converted to Values.
* Add missing attributes.
* Add missing methods, fix 'None' argument type.
* Define properties where possible, remove 'None' argument annotations, remove inadequate type in make_immutable_fields_list.
* Remove absent QueryWrapper. Replace some Any with precise types.
* Fix wrong types and actualize signatures. Deny ManagerDescriptor.__get__ on model instances.
* Use more specific types.
* Arity can be None in subclasses.
* Reformat with black
* Make DeletionMixin generic.
* Fix wrong type variable in _RequestFactory.
* Fix variable name in signature.
* Disallow returning None from Form.clean()
* Allow again returning None from Form.clean
* Drop some unused imports.
* Add tests for MultiValueDict.
* Add tests for utils.timezone.
* Fix#834.
* Add more files to import_all test
* Allow None for `context_object_name`
* Fix CI
* Fix test to work on python 3.8
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
* 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.
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.
* 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