Allow Collection for 'fields' and 'exclude' of form model helpers (#637) (#640)

* Allow Collection for 'fields' and 'exclude' of form model helpers (#637)

There are several functions and classes in `django.forms.models` that
take a `fields` or `exclude` argument. Previously, `Sequence` was used
to annotate these, but the code of Django (I checked version 3.2.4)
doesn't require `__getitem__()` to be implemented, so requiring
`Collection` instead is sufficient.

The practical advantage of requiring `Collection` is that a set, such
as the key set of a dictionary, can be passed without first having to
convert it to a list or tuple.

* Pin mypy to below version 0.900

* Remove Callable for 'fields' and 'exclude' of form model helpers

I cannot find any support for callables for these two arguments in
the code or in the documentation.

* Update setup.py

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Maarten ter Huurne
2021-06-12 00:21:42 +02:00
committed by GitHub
parent 77f9926ce1
commit 8c387e85fe
2 changed files with 3 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ with open("README.md") as f:
readme = f.read()
dependencies = [
"mypy>=0.790",
"mypy>=0.900",
"typing-extensions",
"django",
"django-stubs-ext",