Commit Graph

908 Commits

Author SHA1 Message Date
Jakub Hrabec
c020349f2e Update RunSQL type to include parametrized sql (#1015)
* update RunSQL type to include parametrized sql

* fix Black formatting
2022-06-24 10:08:17 +03:00
w0rp
644052148a Set generic type of SimpleCookie (#1018)
Pyright complains about `response.cookies` because the generic type isn't known. `str` may or may not be the correct type to use here. Something should be set here.
2022-06-23 13:52:31 +03:00
sobolevn
f4407155a5 Do not generate release notes for django-stubs-ext 2022-06-17 18:14:44 +03:00
sobolevn
d6a9a4ef03 Fixing release pipeline 2022-06-17 18:09:00 +03:00
sobolevn
9a23ff864b Fixing release pipeline 2022-06-17 17:54:02 +03:00
sobolevn
4ea9b874f5 Add explicit test for .from_quertset Any fallback 2022-06-17 17:30:27 +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
sobolevn
719cd3a6bc Fix release pipeline 2022-06-17 17:18:15 +03:00
sobolevn
4cf3b445bd Fix release pipeline 2022-06-17 17:15:28 +03:00
sobolevn
f4378112bb Release django-stubs and django-stubs-ext 2022-06-17 17:02:26 +03:00
Adam Birds
86c007d83f Add Feed to monkeypatch to fix generic issue. (#1002)
Fixes #1001
2022-06-17 16:39:11 +03:00
Nikita Sobolev
633030585d Update README.md 2022-06-17 16:33:12 +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
Marti Raudsepp
e45ecd633e Improve hints in migration Operation class (#996) 2022-06-16 09:15:23 +03:00
Aleksander Vognild Burkow
9044a354cb Add fallback related manager in final iteration of AddRelatedManagers (#993)
If a django model has a Manager class that cannot be resolved statically
(if it is generated in a way where we cannot import it, like `objects =
my_manager_factory()`), we fallback to the default related manager, so
you at least get a base level of working type checking.
2022-06-15 18:50:53 +03:00
sterliakov
32e13c37a6 Fix manager types scope (#991)
* Fix manager types scope

* Restore incremental mode and mention in developer docs

* Separate dev mypy config and regular one

* Document config files usage
2022-06-14 20:30:13 +03:00
Adam Johnson
ae5b1a4edf Improve admin filter lookups() return type (#992) 2022-06-13 18:45:55 +03:00
dependabot[bot]
6e84c103af Bump actions/setup-python from 3 to 4 (#989)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-11 09:43:41 +03:00
dependabot[bot]
b6cd673e4c Bump requests from 2.27.1 to 2.28.0 (#990)
Bumps [requests](https://github.com/psf/requests) from 2.27.1 to 2.28.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.27.1...v2.28.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-11 09:43:33 +03:00
Terence Honles
1ce113d743 Enable GitHub auto generated release notes for GitHub releases (#988) 2022-06-11 09:43:24 +03:00
Zac Miller
f7ccf04082 Remove coreapi from requirements.txt (#987) 2022-06-09 00:04:16 +03:00
Terence Honles
a526ba75be remove unneeded submodule (removed in #485) (#982) 2022-06-07 23:07:15 +03:00
Adam Johnson
13c09921f8 Improve admin filter types (#984) 2022-06-07 12:29:44 +03:00
dependabot[bot]
195aaad1fe Bump mypy from 0.960 to 0.961 (#983)
Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.960...v0.961)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-07 12:23:20 +03:00
Terence Honles
42321cabe6 Add GitHub release action to upload to PyPI & create GitHub release (#980)
* Add GitHub release action to upload to PyPI & create GitHub release

* Update .github/workflows/release.yml

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-06-07 12:23:03 +03:00
Anders Kaseorg
24a3b22c60 Move mypy version upper bound to a [compatible-mypy] extra (#979)
* Move mypy version upper bound to a [compatible-mypy] extra

Due to a bug in mypy 0.940 (#870), we made two changes in #871:

• pinned mypy==0.931 in requirements.txt (for running our tests);
• bounded mypy<0.940 in setup.py (for downstream users).

After the mypy bug was quickly fixed upstream in 0.941, our setup.py
bound has been repeatedly raised but not removed (#886, #939, #973).
The only changes in those commits have been to the precise wording of
error messages expected in our tests.  Those wording changes don’t
impact compatibility for downstream users, so it should be safe to go
back to allowing them to upgrade mypy independently.

Since mypy doesn’t yet guarantee backwards compatibility in the plugin
API (although in practice it has rarely been an issue), add a
django-stubs[compatible-mypy] extra for users who prefer a known-good
version of mypy even if it’s a little out of date.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

* Update setup.py

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-06-05 00:08:00 +03:00
Daniel Hahler
43b082850c Fix BaseModelFormSet.save_m2m: accept self (#970)
* Fix BaseModelFormSet.save_m2m: accept `self`

Before it would result in the following when calling it:

> Attribute function "save_m2m" with type "Callable[[], None]" does not accept self argument  [misc]

* fixup! Fix BaseModelFormSet.save_m2m: accept `self`
2022-05-27 13:42:45 +03:00
Ceesjan Luiten
42d8e18bf8 Support content attribute for a Testing Response. (#968)
`content` is a documented attribute of a testing response which isn't part
of the parent HttpResponseBase:

https://docs.djangoproject.com/en/4.0/topics/testing/tools/#testing-responses
2022-05-26 13:17:22 +03:00
Alex Dutton
0a13d2c653 Fix AlterModelManagers managers annotation to be [(str, Manager), ...] (#966)
Django generates AlterModelManagers with Sequence[Tuple[str, Manager]]
arguments — not Sequence[Manager] — as shown by their tests[^1].

[^1]: https://github.com/django/django/blob/4.0.4/tests/migrations/test_operations.py#L3792-L3799

Closes #965.
2022-05-26 12:56:54 +03:00
Allex
fc6fae192e Fix false positive ModelAdmin.list_display_links=None (#964)
* Fix false positive ModelAdmin.list_display_links=None

list_display_links can be set to None to not generate any links in the list display.

https://docs.djangoproject.com/en/4.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display_links

* Update django-stubs/contrib/admin/options.pyi

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-05-26 01:27:11 +03:00
Damian Zaremba
2351051ef1 Upgrade mypy support to 0.960 (#973)
- Updates test_model_field_classes_from_existing_locations to account
  for the behaviour change in https://github.com/python/mypy/pull/12663
- Bumps the version of django-stubs for a new release
2022-05-26 01:20:44 +03:00
Maksim Kurnikov
4a90ad9edc bump version to 1.11.0 (#961) 2022-05-24 11:22:43 +02:00
Mattias Jakobsson
e221f0e053 Sync django.contrib.gis.gdal with upstream (#956) 2022-05-14 08:53:27 +03:00
henribru
8fe2bd4b9b Support passing extra classes to monkeypatch (#953)
* Support passing extra classes to monkeypatch

Closes https://github.com/typeddjango/django-stubs/issues/946#issuecomment-1122895190

* Move extra classes into separate test

* Avoid mutable default

* Fix protocol arguments
2022-05-12 20:14:59 +03:00
Sigurd Ljødal
ccef6779ad Fix type for related fields in values_list querysets (#955)
When fetching a related field in a values_list queryset Django will
return the object primary key, not model instances as was previously
what the mypy plugin assumed.
2022-05-12 09:14:17 +03:00
Sigurd Ljødal
724442b241 Fix type stubs for OuterRef (#952)
* Fix error when nesting OuterRef expressions

OuterRef(OuterRef("my_field")) is a valid expression in nested
subqueries. Mypy would complain that OuterRef was an incompatible type
because OuterRef is typed to only accept str.

* Only fix for OuterRef

* OuterRef is not guaranteed to be resolved to ResolvedOuterRef
2022-05-10 20:44:49 +03:00
Sigurd Ljødal
7d84e5473a Fix type of min_value and max_value on DecimalField (#951)
* Fix type of min_value and max_value on DecimalField

These should at the very least allow Decimals. Technically you can send
in anything that's comparable to a Decimal, but I'm not sure if it makes
sense to allow floats. Could allow both ints and Decimals I guess?

* Allow ints and floats as well

* Update django-stubs/forms/fields.pyi

* Update django-stubs/forms/fields.pyi

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-05-10 20:43:49 +03:00
Marti Raudsepp
1a36c6c379 Improve type hints of URL conf & include() (#949)
* Improve type hints of URL conf & include()

The type of `urlpatterns` list is `List[Union[URLPattern, URLResolver]]`.

* https://docs.djangoproject.com/en/dev/ref/urls/#django.urls.include
* https://docs.djangoproject.com/en/4.0/ref/urls/

* Alias _AnyURL = Union[URLPattern, URLResolver]

* Fix extract_views_from_urlpatterns
2022-05-06 09:00:21 +03:00
dependabot[bot]
4a5d330228 Bump pre-commit from 2.18.1 to 2.19.0 (#950)
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.18.1 to 2.19.0.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.18.1...v2.19.0)

---
updated-dependencies:
- dependency-name: pre-commit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-06 08:57:20 +03:00
sobolevn
69d5aa94b0 Move release.sh to scripts/ 2022-05-02 13:01:38 +03:00
Damian Zaremba
2ef7ff3309 Bump mypy 0.950 (#939)
* Bump mypy to 0.95x

* Remove the * for inferred types

There was an upstream change (https://github.com/python/mypy/pull/12459)
to remove * from inferred types in the reveal_type output.

As we are asserting the * to exist, all the test cases are now failing
on the 0.950 release. Removing the expected * to mirror the upstream
behaviour change should resolve the test failures.
2022-04-29 14:44:33 +03:00
Marti Raudsepp
0caee74490 Fix typecheck default Django version (#944)
Currently running `typecheck_tests.py` without arguments fails with "KeyError: '3.0'"
2022-04-29 10:21:20 +03:00
Marti Raudsepp
e0f45e4778 Update SimpleTestCase.assert method response types (#942)
Since PR 909, SimpleTestCase.client.get() etc methods return a class that no longer derives from `HttpResponse`, but instead `HttpResponseBase`, the `assert*` methods taking response should be updated as well.

Discovered while trying to update djangorestframework-stubs to django-stubs as of master.
2022-04-29 09:03:01 +03:00
Marti Raudsepp
f7b6a7beb4 Fix URLPattern, URLResolver pattern type (#941) 2022-04-29 09:02:19 +03:00
Marti Raudsepp
2b0bfdb46e Restore Python 3.7 compatibility (#945)
django-stubs still supports Python 3.7, but the `/` positional-only parameter syntax is supported only in Python 3.8+.

Not sure why this error wasn't caught in CI.
2022-04-29 08:51:56 +03:00
Marti Raudsepp
c836c3ac3a Fix ValidationError false positive on nested inputs (#943)
Reverts parts of PR 909.
2022-04-28 19:19:18 +03:00
sterliakov
6226381484 Recover after #909 (#925)
* 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_)
2022-04-28 13:01:37 +03:00
Guillaume Andreu Sabater
16499a22ab added unique annotation on model Field (#936) 2022-04-27 22:57:58 +03:00
dependabot[bot]
268ec3bcd5 Bump pytest from 7.1.1 to 7.1.2 (#932)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.1.1 to 7.1.2.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/7.1.1...7.1.2)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 19:58:02 +03:00
Oleg Höfling
8e875b13f7 add fail_silently attribute for BaseEmailBackend instances (#931)
Signed-off-by: Oleg Hoefling <oleg.hoefling@ionos.com>
2022-04-21 19:45:51 +03:00