mirror of https://github.com/zulip/zulip.git
adae8b6d42
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> |
||
---|---|---|
.. | ||
development | ||
__init__.py | ||
alert_words.py | ||
attachments.py | ||
auth.py | ||
compatibility.py | ||
custom_profile_fields.py | ||
digest.py | ||
documentation.py | ||
drafts.py | ||
email_mirror.py | ||
events_register.py | ||
home.py | ||
hotspots.py | ||
invite.py | ||
message_edit.py | ||
message_fetch.py | ||
message_flags.py | ||
message_send.py | ||
muting.py | ||
portico.py | ||
presence.py | ||
push_notifications.py | ||
reactions.py | ||
realm.py | ||
realm_domains.py | ||
realm_emoji.py | ||
realm_export.py | ||
realm_icon.py | ||
realm_linkifiers.py | ||
realm_logo.py | ||
realm_playgrounds.py | ||
registration.py | ||
report.py | ||
storage.py | ||
streams.py | ||
submessage.py | ||
thumbnail.py | ||
tutorial.py | ||
typing.py | ||
unsubscribe.py | ||
upload.py | ||
user_groups.py | ||
user_settings.py | ||
users.py | ||
video_calls.py | ||
zephyr.py |