zulip/analytics
Zixuan James Li adae8b6d42 request: Refactor has_request_variables with ParamSpec.
This makes `has_request_variables` more generic, in the sense of the return
value, and also makes it more accurate, in the sense of requiring the
first parameter of the decorated function to be `HttpRequest`, and
preserving the function signature without using `cast`.

This affects some callers of `has_request_variables` or the callers of its
decoratedfunctions in the following manners:

- Decorated non-view functions called directly in other functions cannot
use `request` as a keyword argument. Becasue `Concatenate` turns the
concatenated parameters (`request: HttpRequest` in this case) into
positional-only parameters. Callers of `get_chart_data` are thus
refactored.

- Functions to be decorated that accept variadic keyword arguments must
define `request: HttpRequest` as positional-only. Mypy in strict mode
rejects such functions otherwise because it is possible for the caller to
pass a keyword argument that has the same name as `request` for `**kwargs`.
No defining `request: HttpRequest` as positional-only breaks type safety
because function with positional-or-keyword parameters cannot be considered
a subtype of a function with the same parameters in which some of them are
positional-only.

Consider `f(x: int, /, **kwargs: object) -> int` and `g(x: int,
**kwargs: object) -> int`. `f(12, x="asd")` is valid but `g(12, x="asd")`
is not.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-08-06 16:19:48 -07:00
..
lib analytics: Add Composable type annotations. 2022-07-30 06:46:34 -07:00
management actions: Split out zerver.actions.create_realm. 2022-04-14 17:14:37 -07:00
migrations typing: Use BaseDatabaseSchemaEditor in place of DatabaseSchemaEditor. 2022-05-30 14:18:53 -07:00
tests support: Correctly show Unspecified org type at /activity/support. 2022-07-29 14:56:34 -07:00
views request: Refactor has_request_variables with ParamSpec. 2022-08-06 16:19:48 -07:00
__init__.py Create "analytics" app with activity reports. 2013-11-06 12:07:32 -05:00
models.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
urls.py analytics: Use user IDs to get user activity summaries. 2021-10-13 15:30:27 -07:00