19 Commits
Author SHA1 Message Date
Petter FribergandAdam Johnson 6aecafc64f Improve type of TestCase.captureOnCommitCallbacks (#1202)
Co-authored-by: Adam Johnson <me@adamj.eu>
2022-10-25 09:47:09 +01:00
Petter Friberg adb26248db Allow assertQuerySetEqual to compare with a collection of values (#1201) 2022-10-25 00:50:08 +03:00
Petter Friberg 54d5835f66 Implement support for <QuerySet>.as_manager() (#1025)
* Implement support for `<QuerySet>.as_manager()`

* fixup! Implement support for `<QuerySet>.as_manager()`

* fixup! fixup! Implement support for `<QuerySet>.as_manager()`
2022-09-29 15:05:25 +03:00
Petter Friberg 6f9afd3cc9 Relax fields= arg for refresh_from_db to accept Sequence (#1156) 2022-09-19 23:14:08 +01:00
Petter Friberg a2a3543198 Adjust choices= type variance for model fields (#1154)
Avoid getting stuck in an invariance pit. I don't think it makes sense
to mix two tuple with named group elements in same choices sequence(?).

This also changes the outermost container type to `Sequence` as e.g.
both `tuple` and `list` are supported.
2022-09-19 13:17:17 +03:00
Petter Friberg b34ebe7553 Serialize RelatedManager attributes in cache (#1152) 2022-09-15 23:54:10 +03:00
Petter FribergandNikita Sobolev 8bd00ba25a Type samesite values as literals 'Lax', 'Strict' or 'None' (#1110)
* Type `samesite` values as literals 'Lax', 'Strict' or 'None'

- Adjusts supported `SESSION_COOKIE_SAMESITE` values
- Adjusts supported `CSRF_COOKIE_SAMESITE` values

* Update django-stubs/conf/global_settings.pyi

* Update response.pyi

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-08-27 02:02:47 +03:00
Petter Friberg 2a6f4647f0 Populate model argument for dynamically created managers (#1033)
* Populate model for dynamically created managers

* fixup! Populate model for dynamically created managers
2022-06-30 10:25:29 +03:00
Petter Friberg 023106fe45 Emit error and set fallback type for managers that can't be resolved (#999)
* Emit error and set fallback type for managers that can't be resolved

* fixup! Emit error and set fallback type for managers that can't be resolved
2022-06-17 17:19:42 +03:00
Petter Friberg 8d8b8cd1fc Set type of default django.core.cache.cache to BaseCache (#998)
* Set type of default `django.core.cache` to `BaseCache`

- The previous type `ConnectionProxy` is just a proxy class, thus
  revealing `Any` for _all_ cache methods

* fixup! Set type of default `django.core.cache` to `BaseCache`
2022-06-16 23:33:37 +03:00
Petter Friberg 0e98cc9114 Don't rely on django.db.models.manager.Manager metadata for dynamically created manager (#904) 2022-03-31 23:37:37 +03:00
Petter Friberg 92e5f202ac Cache dynamically created manager nodes (#840)
- Non plugin generated, "cross_ref"s points to dynamically
  created managers (e.g. `Model.objects`) and can make Mypy fail on
  cached runs
2022-03-31 10:21:21 +03:00
Petter Friberg 8aae836a26 Model.__init__ supporting same typing as assigment (#835)
* `Model.__init__` supporting same typing as assigment

* Update mypy_django_plugin/django/context.py
2022-01-29 12:07:26 +03:00
Petter FribergandNikita Sobolev 515e382d4a Fix .filter-kwargs lookup crash during cached runs (#828)
* Fix .filter-kwargs lookup crash during cached runs

* Update mypy_django_plugin/lib/helpers.py

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-01-24 13:24:09 +03:00
Petter Friberg 220f0e4cf0 Reuse reverse managers instead of recreating (#825) 2022-01-22 21:13:05 +03:00
Petter Friberg edec5a1c99 Notify when Manager.from_queryset happens inside model class body (#824)
* Refactor to more easily support additional config options

* Notify when Manager.from_queryset happens inside model class body

- A warning will be emitted whenever `Manager.from_queryset` happens
  inside of a model class body

* Resolve generated default manager types before final iteration

A default manager on a model should always exist, eventually. Although,
we extend to look through dynamically generated managers on each
iteration instead of deferring until the final iteration.
2022-01-21 19:46:56 +03:00
Petter Friberg a9e41a8ba9 Fix suggested changes from #820 (#821) 2022-01-16 21:13:47 +03:00
Petter Friberg 99f28387fb Set custom queryset methods as manager attrs instead of method copies (#820)
Instead of copying methods over from a QuerySet passed to a basemanager
when invoking '<BaseManager>.from_queryset', any QuerySet methods are
declared as attributes on the manager.

This allows us to properly lookup any QuerySet method types via a
'get_attribute_hook' and will thus remove disorienting phantom errors
occuring from mypy trying to resolve types only existing in the module
where the _original_ (and real) queryset method was declared.
2022-01-16 12:14:33 +03:00
Petter Friberg 48aaf3d2ac Implement stubs for views.decorators.common.no_append_slash (#743) 2021-11-01 18:04:58 +03:00