zulip/zerver/views
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
..
development settings: Make INVITATION_LINK_VALIDITY_MINUTES optional. 2022-07-26 17:07:48 -07:00
__init__.py
alert_words.py actions: Split out zerver.actions.alert_words. 2022-04-14 17:14:31 -07:00
attachments.py actions: Split out zerver.actions.uploads. 2022-04-14 17:14:32 -07:00
auth.py request: Refactor has_request_variables with ParamSpec. 2022-08-06 16:19:48 -07:00
compatibility.py django: Use HttpRequest.headers. 2022-05-13 20:42:20 -07:00
custom_profile_fields.py custom_profile: Use cast to ensure ProfieDataElementUpdateDict. 2022-07-15 14:55:03 -07:00
digest.py mypy: Fix most AnonymousUser type errors. 2021-07-24 14:55:46 -07:00
documentation.py openapi: Fuse generate_api_title with generate_api_description. 2022-07-22 16:41:55 -07:00
drafts.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
email_mirror.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
events_register.py events_register: Pass spectator set language to client in user_settings. 2022-07-14 14:27:32 -07:00
home.py typing: Add none-checks for miscellaneous cases. 2022-05-31 09:43:55 -07:00
hotspots.py actions: Split out zerver.actions.hotspots. 2022-04-14 17:14:31 -07:00
invite.py settings: Make INVITATION_LINK_VALIDITY_MINUTES optional. 2022-07-26 17:07:48 -07:00
message_edit.py actions: Split out zerver.actions.message_edit. 2022-04-14 17:14:36 -07:00
message_fetch.py python: Unquote some unnecessarily quoted type annotations. 2022-06-26 17:37:41 -07:00
message_flags.py message_flags: Add an assertion check for stream.recipient_id. 2022-07-26 18:00:24 -07:00
message_send.py python: Use a real parser for email addresses. 2022-07-29 15:47:33 -07:00
muting.py muting: Add validation for update operations. 2022-07-25 14:03:08 -07:00
portico.py middleware: Fix URL encoding of next parameter. 2022-05-12 17:51:51 -07:00
presence.py actions: Split out zerver.actions.presence. 2022-04-14 17:14:32 -07:00
push_notifications.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
reactions.py actions: Split out zerver.actions.reactions. 2022-04-14 17:14:35 -07:00
realm.py realm_reactivation: Prevent realm reactivation link reuse. 2022-07-26 17:14:26 -07:00
realm_domains.py actions: Split out zerver.actions.realm_domains. 2022-04-14 17:14:37 -07:00
realm_emoji.py realm: Create RealmAuditLog entries when removing custom emoji. 2022-07-31 18:32:28 -07:00
realm_export.py actions: Split out zerver.actions.realm_export. 2022-04-14 17:14:31 -07:00
realm_icon.py upload: Add assertions before accessing uploaded files. 2022-06-23 22:09:05 -07:00
realm_linkifiers.py realm: Create RealmAuditLog entry when removing realm linkifiers. 2022-07-31 18:32:28 -07:00
realm_logo.py upload: Add assertions before accessing uploaded files. 2022-06-23 22:09:05 -07:00
realm_playgrounds.py actions: Split out zerver.actions.realm_playgrounds. 2022-04-14 17:14:30 -07:00
registration.py confirmation: Prevent re-use of email change links. 2022-07-26 17:14:26 -07:00
report.py report: Correct type annotation allowing unauth access. 2022-07-26 18:00:24 -07:00
storage.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
streams.py streams: Rename admin_access_required to unsubscribing_others. 2022-07-26 17:25:52 -07:00
submessage.py actions: Split out zerver.actions.submessage. 2022-04-14 17:14:30 -07:00
thumbnail.py docs: Remove some outdated references to thumbnailing.md doc. 2022-07-12 17:44:24 -07:00
tutorial.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
typing.py actions: Split out zerver.actions.typing. 2022-04-14 17:14:30 -07:00
unsubscribe.py confirmation: Tighten logic around the mark_object_used parameter. 2022-07-21 15:18:15 -07:00
upload.py upload: Refactor file size out of get_file_info. 2022-07-29 14:09:12 -07:00
user_groups.py user_groups: Rename existing_subgroups variable to existing_direct_subgroup_ids. 2022-05-17 14:51:55 -07:00
user_settings.py get_object_from_key: Make mark_object_used an obligatory kwarg. 2022-07-21 15:18:15 -07:00
users.py python: Use a real parser for email addresses. 2022-07-29 15:47:33 -07:00
video_calls.py actions: Split out zerver.actions.video_calls. 2022-04-14 17:14:30 -07:00
zephyr.py python: Use a real parser for email addresses. 2022-07-29 15:47:33 -07:00