Files
django-stubs/tests
PIG208 516deba2fa Improve stubs with minor fixes (#1038)
* Add a missing attribute to Jinja2.

https://github.com/django/django/blob/main/django/template/backends/jinja2.py#L35

Signed-off-by: Zixuan James Li <p359101898@gmail.com>

* Make _QuerySet.extra's signature more generic.

This makes sure that we don't reject tuples, which is also valid
according to the implementation.

Relevant source code:
03eec9ff6c/django/db/models/sql/where.py (L271-L281)
03eec9ff6c/django/db/models/sql/query.py (L2307-L2308)

Signed-off-by: Zixuan James Li <p359101898@gmail.com>

* Fix user_passes_test to use AUTH_USER_MODEL.

According to the documentation, `test_func` is a callable that takes a
`User` (possibly anonymous).

Relevant documentation:
https://docs.djangoproject.com/en/4.0/topics/auth/default/#django.contrib.auth.decorators.user_passes_test

Signed-off-by: Zixuan James Li <p359101898@gmail.com>

* Add more accurate type annotations for dirs.

Though not documented, it's possible for `dirs` to contain
`pathlib.Path`.

`django.template.loaders.app_directories.Loader` is an example for this:
03eec9ff6c/django/template/loaders/app_directories.py
03eec9ff6c/django/template/utils.py (L97-L111)

Signed-off-by: Zixuan James Li <p359101898@gmail.com>

* serve should return FileResponse.

There are several serve functions that should return a `FileResponse`.

Source code:
863aa7541d/django/views/static.py (L17-L53)
863aa7541d/django/contrib/staticfiles/views.py (L15-L39)
863aa7541d/django/contrib/staticfiles/handlers.py (L48-L50)
863aa7541d/django/test/testcases.py (L1680-L1687)

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-04 23:46:53 +03:00
..