mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-12 23:16:31 +08:00
* 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.
42 lines
1.9 KiB
Python
42 lines
1.9 KiB
Python
ABSTRACT_USER_MODEL_FULLNAME = "django.contrib.auth.models.AbstractUser"
|
|
PERMISSION_MIXIN_CLASS_FULLNAME = "django.contrib.auth.models.PermissionsMixin"
|
|
MODEL_CLASS_FULLNAME = "django.db.models.base.Model"
|
|
FIELD_FULLNAME = "django.db.models.fields.Field"
|
|
CHAR_FIELD_FULLNAME = "django.db.models.fields.CharField"
|
|
ARRAY_FIELD_FULLNAME = "django.contrib.postgres.fields.array.ArrayField"
|
|
AUTO_FIELD_FULLNAME = "django.db.models.fields.AutoField"
|
|
GENERIC_FOREIGN_KEY_FULLNAME = "django.contrib.contenttypes.fields.GenericForeignKey"
|
|
FOREIGN_KEY_FULLNAME = "django.db.models.fields.related.ForeignKey"
|
|
ONETOONE_FIELD_FULLNAME = "django.db.models.fields.related.OneToOneField"
|
|
MANYTOMANY_FIELD_FULLNAME = "django.db.models.fields.related.ManyToManyField"
|
|
DUMMY_SETTINGS_BASE_CLASS = "django.conf._DjangoConfLazyObject"
|
|
|
|
QUERYSET_CLASS_FULLNAME = "django.db.models.query._QuerySet"
|
|
BASE_MANAGER_CLASS_FULLNAME = "django.db.models.manager.BaseManager"
|
|
MANAGER_CLASS_FULLNAME = "django.db.models.manager.Manager"
|
|
RELATED_MANAGER_CLASS = "django.db.models.manager.RelatedManager"
|
|
|
|
WITH_ANNOTATIONS_FULLNAME = "django_stubs_ext.WithAnnotations"
|
|
ANNOTATIONS_FULLNAME = "django_stubs_ext.annotations.Annotations"
|
|
|
|
BASEFORM_CLASS_FULLNAME = "django.forms.forms.BaseForm"
|
|
FORM_CLASS_FULLNAME = "django.forms.forms.Form"
|
|
MODELFORM_CLASS_FULLNAME = "django.forms.models.ModelForm"
|
|
|
|
FORM_MIXIN_CLASS_FULLNAME = "django.views.generic.edit.FormMixin"
|
|
|
|
MANAGER_CLASSES = {
|
|
MANAGER_CLASS_FULLNAME,
|
|
BASE_MANAGER_CLASS_FULLNAME,
|
|
}
|
|
|
|
RELATED_FIELDS_CLASSES = {FOREIGN_KEY_FULLNAME, ONETOONE_FIELD_FULLNAME, MANYTOMANY_FIELD_FULLNAME}
|
|
|
|
MIGRATION_CLASS_FULLNAME = "django.db.migrations.migration.Migration"
|
|
OPTIONS_CLASS_FULLNAME = "django.db.models.options.Options"
|
|
HTTPREQUEST_CLASS_FULLNAME = "django.http.request.HttpRequest"
|
|
|
|
F_EXPRESSION_FULLNAME = "django.db.models.expressions.F"
|
|
|
|
ANY_ATTR_ALLOWED_CLASS_FULLNAME = "django._AnyAttrAllowed"
|