mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-16 00:37:11 +08:00
* 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:
committed by
GitHub
parent
77f9926ce1
commit
8c387e85fe
@@ -2,6 +2,7 @@ from datetime import datetime
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Collection,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
@@ -36,7 +37,7 @@ from django.db.models import ForeignKey
|
||||
|
||||
ALL_FIELDS: str
|
||||
|
||||
_Fields = Union[List[Union[Callable, str]], Sequence[str], Literal["__all__"]]
|
||||
_Fields = Union[Collection[str], Literal["__all__"]]
|
||||
_Labels = Dict[str, str]
|
||||
_ErrorMessages = Dict[str, Dict[str, str]]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user