Commit Graph

802 Commits

Author SHA1 Message Date
rolandcrosby-check
1da693ebff Fix extra_context argument type in admin views (#816)
The `extra_context` argument to `ModelAdmin.changeform_view`,
`add_view`, `change_view`, `changelist_view`, `delete_view`, and
`history_view` is used to pass extra context variables to a template, so
all of these arguments should have type `Optional[Dict[str, Any]]`.
Instead, these are currently typed as `Optional[Dict[str, bool]]`,
`Optional[Dict[str, str]]`, or `None`.
2022-01-13 23:03:03 +03:00
rolandcrosby-check
3c1e9e3884 Allow Iterable[Iterable[Any]] as args_generator argument to format_html_join (#722)
* Allow List[Tuple[Any]] as args_generator argument to format_html_join

format_html_join's args_generator argument can be anything that contains
tuples of things that can be coerced to strings or that have a
`__html__` method.

Fixes #721.

* Use `Iterable[Iterable[Any]]` as `args_generator` type

* Run linter
2022-01-12 09:44:14 +03:00
dependabot[bot]
4cdf8a8d39 Bump pytest-mypy-plugins from 1.9.2 to 1.9.3 (#815)
Bumps [pytest-mypy-plugins](https://github.com/TypedDjango/pytest-mypy-plugins) from 1.9.2 to 1.9.3.
- [Release notes](https://github.com/TypedDjango/pytest-mypy-plugins/releases)
- [Changelog](https://github.com/typeddjango/pytest-mypy-plugins/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TypedDjango/pytest-mypy-plugins/compare/1.9.2...1.9.3)

---
updated-dependencies:
- dependency-name: pytest-mypy-plugins
  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-01-12 09:42:53 +03:00
rolandcrosby-check
7701957e4f Fix annotation of ModelAdmin.get_object (#812)
* Fix annotation of ModelAdmin.get_object

The type annotation in django-stubs indicated that the type of the
`from_field` argument to `ModelAdmin.get_object` should be `None`. In
fact, `None` is the default value of that argument. If the argument is
not `None`, [it is passed to a model's `_meta.get_field` method][impl], which
takes an argument of type `Union[Callable[..., Any], str`.

[impl]: ac5cc6cf01/django/contrib/admin/options.py (L767)

* Fix formatting
2022-01-08 10:48:29 +03:00
dependabot[bot]
fafb200e90 Bump requests from 2.27.0 to 2.27.1 (#807)
Bumps [requests](https://github.com/psf/requests) from 2.27.0 to 2.27.1.
- [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.0...v2.27.1)

---
updated-dependencies:
- dependency-name: requests
  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-01-06 12:39:00 +03:00
Tom Carrick
118f50307c Allow expressions in UniqueConstraint (#806)
* Allow expressions in UniqueConstraint

* Use ellipsis

* And for fields
2022-01-06 12:07:24 +03:00
Abhyudai
3761c16c51 Change return type of queryset.bulk_update to int (#683)
- the change was made in the commit cd124295d8.
2022-01-05 18:42:47 +03:00
Gergely Kalmár
c65e2c48db Add typing to mypy plugin (#804) 2022-01-05 16:21:14 +03:00
Nikita Sobolev
ed68fbc99f Update typecheck_tests.py 2022-01-04 20:32:50 +03:00
Nikita Sobolev
9cad4fbfeb Delete misspel.yml 2022-01-04 20:32:18 +03:00
dependabot[bot]
3a27d8bb91 Bump requests from 2.26.0 to 2.27.0 (#803)
Bumps [requests](https://github.com/psf/requests) from 2.26.0 to 2.27.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.26.0...v2.27.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-01-04 11:19:24 +03:00
Carl Johan Hambro
49bed6c28d Fix type for templatetag (#801) 2021-12-31 11:56:10 +03:00
Gabriel Augendre
3b02222beb Update syndication Feed class (#800)
* Update syndication Feed class

* Fix typing
2021-12-30 16:33:29 +03:00
Cory Dolphin
9483865284 Make geos.GEOSGeometryBase.equals_exact accept float (#796) 2021-12-29 11:16:16 +03:00
Gabriel Augendre
1834242e46 Fix Feed.get_object signature (#798)
get_object's default implementation returns None but subclasses
are allowed to override this method and make it return anything.

The returned object would then be passed to other methods
to publish different data for different URL parameters.

https://docs.djangoproject.com/en/4.0/ref/contrib/syndication/
2021-12-29 11:07:43 +03:00
sobolevn
3b303480b3 Rename requirements.txt file for dependabot to work 2021-12-25 11:11:15 +03:00
Nikita Sobolev
b883e192e4 Adds better id and pk handling (#791) 2021-12-18 13:09:22 +03:00
w0rp
4a0dd04611 Set types for on_delete functions (#772)
Set types for on_delete functions so they can be provided as values to
the on_delete attribute of ForeignKey in Pyright's strict mode.
2021-12-17 22:20:01 +03:00
Nikita Sobolev
feb0bfa4a6 Updates deps (#788)
* Updates deps

* Updates deps
2021-12-16 22:39:12 +03:00
Nikita Sobolev
02a39f722d Replace toml with tomli (#787)
* Replace `toml` with `tomli`

* Replace `toml` with `tomli`
2021-12-16 22:19:34 +03:00
Nikita Sobolev
b50a9077f8 Adds django@4.0 support (#786)
* Adds django@4.0 support

* Fixes CI

* Fixes CI

* Ignore new error for django4.0

* Fixes
2021-12-16 21:51:46 +03:00
sobolevn
e9b328a935 Updates deps, adds mypy@0.920 compat, adds dependabot 2021-12-16 13:11:06 +03:00
Nikita Sobolev
eb80b949af Refs #774 (#777)
* Refs #774

* Update test_create.yml
2021-12-15 15:53:24 +03:00
Chris Beaven
1219d62b6a Add Model._base_manager (#776) 2021-12-15 09:08:45 +03:00
Chris Beaven
daf6c659f0 Update autoreload to Django 3.2 (#775)
* Update autoreload stub to Django 3.2

* Fix some subclass return types

* types for watchmanreloader attributes

* Don't reference an redundant attribute in WatchmanReloader
2021-12-15 09:06:32 +03:00
w0rp
059471101c Fix the get_field type for Pyright (#773)
This PR fixes the type of get_field so it won't report errors in
Pyright's strictest type checking mode.
2021-12-13 20:05:23 +03:00
Vadim Safonov
ccbbf86d0e Update signature for Django 3.1 Paginator (#770) 2021-12-09 22:35:32 +03:00
Chris Beaven
69d4b1a86d More accurate template.Parser parse_until type (#769) 2021-12-09 11:26:26 +03:00
Marti Raudsepp
6436a10d5a Add more precise RunSQL, RunPython migration hints (#768) 2021-12-08 15:11:35 +03:00
Marti Raudsepp
79d34d6f46 Add ValidationError type hints (#767) 2021-12-08 15:09:20 +03:00
Kevin Marsh
e5361f1e04 Fix QuerySet.create and Manager.create annotation since it doesn't accept *args (only **kwargs) (#762) 2021-11-30 18:37:54 +03:00
Stanislav Mikhailov
593d04d6e9 Fixed the types in ManyToManyField according to their definition in Django. (#758) 2021-11-24 01:13:45 +03:00
Sigurd Ljødal
a57ae4fc76 Fix BaseConnectionWrapper.execute_wrapper (#752)
This is a context manager, not an iterator.

Currently mypy will complain if it's used as documented.
2021-11-15 18:14:42 +03:00
David Cain
331042d1c7 Add signature for Django 3.2 TimestampSigner (#751)
Django 3.2 introduced two new methods: `sign_object` and
`unsign_object` which can sign/unsign "complex data structures" such as
lists, tuples, dictionaries:

https://docs.djangoproject.com/en/3.2/topics/signing/#django.core.signing.TimestampSigner

Because the methods take an arbitrary serializer (a JSON serializer by
default, but not guaranteed), we cannot be sure of the type of `obj`.
2021-11-13 22:56:27 +03:00
Avery Fischer (biggerfisch)
b5c20100ff Update MigrationExecutor stubs to use Sequence (#749)
There is no need for a specific List type here, using a higher type
works fine and allows more working code to pass type-checking.
2021-11-12 20:10:24 +03:00
Petter Friberg
48aaf3d2ac Implement stubs for views.decorators.common.no_append_slash (#743) 2021-11-01 18:04:58 +03:00
Chris Beaven
640553dcd7 Fix boundfield method parameters (#741) 2021-10-26 14:34:08 +03:00
Yukio Mizuta
95060b54c2 Update send_mail recipient_list type from List[str] to Sequence[str] (#740) 2021-10-22 21:51:57 +03:00
Simon Charette
09c3dc894b Adjust django.core.signing.dumps and loads key type. (#739)
An optional key can be provided to these functions.
2021-10-22 21:02:01 +03:00
9482f2f81c fix django.contrib.auth.models.Group.natural_key no return type (#724) 2021-10-19 15:03:53 +03:00
Brian Helba
676750e090 Add a definition for Storage.get_alternative_name (#732)
See: f5802a21c4/django/core/files/storage.py (L65)
2021-10-19 14:53:22 +03:00
Brian Helba
7c87c720ad Correct the type of FileField.storage (#731)
* Correct the type of FileField.storage

This instance property can't be a callable. Although the FileField constructor
allows a callable, it is immediately resolved to an instance of Storage.
See: f5802a21c4/django/db/models/fields/files.py (L231-L235)

* Correct the type of FieldFile.storage

This instance property is copied directly from `FileField.storage` and should be
the same type.
See: f5802a21c4/django/db/models/fields/files.py (L21)
2021-10-19 14:40:17 +03:00
Rob Percival
9938378e94 Make AddRelatedManagers look for "objects" on parent model (#730)
* Add failing test for relation to model inheriting `objects`

Fails with:
```
pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output:
Expected:
  main:2: note: Revealed type is "myapp.models.MyUser*"
  main:3: note: Revealed type is "myapp.models.MyUser*"
  <45 (diff)
  <45 (diff)
Actual:
  main:2: note: Revealed type is "myapp.models.MyUser*"
  main:3: note: Revealed type is "myapp.models.MyUser*"
  main:6: error: "MyUser" has no attribute "book_set" (diff)
  main:6: note: Revealed type is "Any"          (diff)
  main:7: error: "MyUser" has no attribute "article_set" (diff)
  main:7: note: Revealed type is "Any"          (diff)
```

* Make AddRelatedManagers look for "objects" on parent model

Previously, AddRelatedManagers would fail if a related model had inherited
its `objects` field from a parent class. This would result in missing
relation attributes. This is fixed by using `get()` instead of `names`;
the former searches the MRO for the symbol, whereas the latter only looks
for symbols declared directly on the class.
2021-10-19 14:31:14 +03:00
Nikita Sobolev
7ac33f3a28 Fixes CI (#734)
* Fixes CI

* Fixes CI

* Fixes CI
2021-10-19 14:10:25 +03:00
Terence Honles
fb12560981 update all path related operations to have more accurate types (#713) 2021-09-11 22:41:16 +03:00
Terence Honles
799b41fe47 fix typing on HttpResponse and StreamingHttpResponse (#712)
While the documentation for `HttpResponse` and `StreamingHttpResponse`
*says* `content` and `streaming_content` should be bytestrings [1] or an
iterable of bytestrings respectively [2], this is not what the API
supports [3] [4] and there are tests which make sure the API supports
more than bytestrings [5] [6] [etc]. Before assigning `content` or
`streaming_content` the code paths will call  `self.make_bytes` to
coerce the value to bytes.

[1]: ecf87ad513/django/http/response.py (L324-L327)
[2]: 0a28b42b15/django/http/response.py (L395-L399)
[3]: ecf87ad513/django/http/response.py (L342-L362)
[4]: 0a28b42b15/django/http/response.py (L415-L427)
[5]: 0a28b42b15/tests/cache/tests.py (L2250)
[6]: 0a28b42b15/tests/i18n/urls.py (L8)
2021-09-10 23:18:20 +03:00
Terence Honles
fb4d20475b add HashedFilesMixin.url argument force (#714) 2021-09-10 10:02:48 +03:00
Craig
a1f3712c43 Add SmallAutoField (#710)
* Add SmallAutoField

* Test SmallAutoField presents as int
2021-09-09 15:58:03 +03:00
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