Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

endpoints: Modify comments mentioning has_request_variables and REQ.

Kenneth Rodrigues1d580f143ed4
diff --git a/zerver/lib/types.py b/zerver/lib/types.py
index 055c19d6353..1c42e86abcc 100644
--- a/zerver/lib/types.py
+++ b/zerver/lib/types.py
@@ -79,7 +79,7 @@ class UnspecifiedValue:
We use this type as an explicit sentinel value for such endpoints.
TODO: Can this be merged with the _NotSpecified class, which is
- currently an internal implementation detail of the REQ class?
+ currently an internal implementation detail of the typed_endpoint?
"""
diff --git a/zerver/tests/test_bots.py b/zerver/tests/test_bots.py
index 9ad1ae31be0..b4f97532bd4 100644
--- a/zerver/tests/test_bots.py
+++ b/zerver/tests/test_bots.py
@@ -1619,7 +1619,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
result = self.client_post(f"/json/bots/{self.get_bot_user(email).id}", bot_info)
# TODO: The "method" parameter is not currently tracked as a processed parameter
- # by has_request_variables. Assert it is returned as an ignored parameter.
+ # by typed_endpoint. Assert it is returned as an ignored parameter.
response_dict = self.assert_json_success(result, ignored_parameters=["method"])
self.assertEqual("Fred", response_dict["full_name"])
diff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.py
index 15de974e4e8..7090d178050 100644
--- a/zerver/tests/test_openapi.py
+++ b/zerver/tests/test_openapi.py
@@ -452,7 +452,7 @@ do not match the types declared in the implementation of {function.__name__}.\n"
method: str,
tags: set[str],
) -> None:
- # Our accounting logic in the `has_request_variables()`
+ # Our accounting logic in the `typed_endpoint`
# code means we have the list of all arguments
# accepted by every view function in arguments_map.
accepted_arguments = set(arguments_map[function_name])
@@ -477,7 +477,7 @@ so maybe we shouldn't include it in pending_endpoints.
try:
# Don't include OpenAPI parameters that live in
- # the path; these are not extracted by REQ.
+ # the path; these are not extracted by typed_endpoint.
openapi_parameters = get_openapi_parameters(
url_pattern, method, include_url_parameters=False
)
@@ -493,8 +493,7 @@ so maybe we shouldn't include it in pending_endpoints.
# some processing to match with OpenAPI rules
#
# * accepted_arguments is the full set of arguments
- # this method accepts (from the REQ declarations in
- # code).
+ # this method accepts.
#
# * The documented parameters for the endpoint as recorded in our
# OpenAPI data in zerver/openapi/zulip.yaml.
@@ -527,12 +526,12 @@ so maybe we shouldn't include it in pending_endpoints.
def test_openapi_arguments(self) -> None:
"""This end-to-end API documentation test compares the arguments
- defined in the actual code using @has_request_variables and
- REQ(), with the arguments declared in our API documentation
+ defined in the actual code using @typed_endpoint,
+ with the arguments declared in our API documentation
for every API endpoint in Zulip.
First, we import the fancy-Django version of zproject/urls.py
- by doing this, each has_request_variables wrapper around each
+ by doing this, each typed_endpoint wrapper around each
imported view function gets called to generate the wrapped
view function and thus filling the global arguments_map variable.
Basically, we're exploiting code execution during import.
@@ -540,7 +539,7 @@ so maybe we shouldn't include it in pending_endpoints.
Then we need to import some view modules not already imported in
urls.py. We use this different syntax because of the linters complaining
of an unused import (which is correct, but we do this for triggering the
- has_request_variables decorator).
+ typed_endpoint decorator).
At the end, we perform a reverse mapping test that verifies that
every URL pattern defined in the OpenAPI documentation actually exists
@@ -575,11 +574,11 @@ so maybe we shouldn't include it in pending_endpoints.
if function is get_events:
# Work around the fact that the registered
# get_events view function isn't where we do
- # @has_request_variables.
+ # @typed_endpoint.
#
# TODO: Make this configurable via an optional argument
- # to has_request_variables, e.g.
- # @has_request_variables(view_func_name="zerver.tornado.views.get_events")
+ # to typed_endpoint, e.g.
+ # @typed_endpoint(view_func_name="zerver.tornado.views.get_events")
function = get_events_backend
function_name = f"{function.__module__}.{function.__name__}"
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index 0a93be2a1ea..e0c94b78d3a 100644
--- a/zerver/views/realm.py
+++ b/zerver/views/realm.py
@@ -338,7 +338,7 @@ def update_realm(
#
# TODO: It should be possible to deduplicate this function up
# further by some more advanced usage of the
- # `REQ/has_request_variables` extraction.
+ # `typed_endpoint` extraction.
req_vars = {}
req_group_setting_vars = {}
diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py
index 89432e04cd5..abc7172da1d 100644
--- a/zerver/views/user_settings.py
+++ b/zerver/views/user_settings.py
@@ -168,7 +168,7 @@ def check_settings_values(
email_notifications_batching_period_seconds: int | None,
default_language: str | None = None,
) -> None:
- # We can't use REQ for this widget because
+ # We can't use typed_endpoint for this widget because
# get_available_language_codes requires provisioning to be
# complete.
if default_language is not None and default_language not in get_available_language_codes():