8 Commits
Author SHA1 Message Date
Brian Helba 676750e090 Add a definition for Storage.get_alternative_name (#732)
See: https://github.com/django/django/blob/f5802a21c401b92764a9f3e2886144f3c5d77573/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: https://github.com/django/django/blob/f5802a21c401b92764a9f3e2886144f3c5d77573/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: https://github.com/django/django/blob/f5802a21c401b92764a9f3e2886144f3c5d77573/django/db/models/fields/files.py#L21
2021-10-19 14:40:17 +03:00
Brian HelbaandNikita Sobolev 619823d497 Ensure that all registered checks return a list of CheckMessage (#508)
* Ensure that all registered checks return a list of CheckMessage

This changes missing and Any return types on registered checks to always
return "List[CheckMessage]".

In many cases, check functions were already annotated to return in a more
specific type than CheckMessage (e.g. Error). In these cases, it's assumed
that the existing annotation is correct, and the more specific type is kept.

* Update model_checks.pyi

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2021-05-01 13:34:38 +03:00
Brian Helba a3624dec36 Provide a more specific signature for django.core.checks.register (#509)
This also corrects the fact that "run_checks" only returns a concatenated list
of all registered check results, which may only contain CheckMessage:
https://github.com/django/django/blob/302caa40e4caab7d95ef7d0a88a90f935039ab09/django/core/checks/registry.py#L60
2020-10-29 10:31:26 +03:00
Brian Helba 6dc2c32382 Ensure that all registered checks take the same parameters (#499)
The Django API requires that registered checks take an "app_configs"
argument, which is a list of AppConfig. This is practically also passed by
keyword, so all parameters should be specified with a "= ..." to indicate
that they are keywords.

Django always passed "app_configs" as a list, but checks can accept and
use a more general more Sequence.

The Django API also requires that registered checks take "**kwargs".

This results in the canonical parameters of:
"app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any"
2020-10-29 02:21:32 +03:00
Brian Helba 695cdb16ca Add django.forms.widgets.FILE_INPUT_CONTRADICTION symbol (#506)
https://github.com/django/django/blob/302caa40e4caab7d95ef7d0a88a90f935039ab09/django/forms/widgets.py#L399
2020-10-29 02:20:40 +03:00
Brian Helba 9d4d06f8b3 Allow overridable checks to be CheckMessage (#497)
* Allow overridable checks to be CheckMessage

The checks framework expects return types to be "List[CheckMessage]". This
allows all overridable checks-returning methods to return the more general
"CheckMessage", instead of the "Error" subclass.

* Ignore an incorrect usage of the checks API in Django 2.2
2020-10-22 15:12:36 +03:00
Brian Helba d96aee7a8b Fix the type of form.Field.widget (#321)
The `widget` class attribute of `form.Field` expects a `Widget` class, not an instance of `Widget`.

See: https://docs.djangoproject.com/en/3.0/ref/forms/fields/#widget
Also usages at: https://github.com/django/django/blob/3259983f569151232d8e3b0c3d0de3a858c2b265/django/forms/fields.py#L46
2020-02-07 12:42:02 +03:00