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.

realm_playgrounds: Remove unnecessary Any for kwargs.

Zixuan James Li131729a06ce2
diff --git a/zerver/actions/realm_playgrounds.py b/zerver/actions/realm_playgrounds.py
index a16c8817c50..6d65302fe4a 100644
--- a/zerver/actions/realm_playgrounds.py
+++ b/zerver/actions/realm_playgrounds.py
@@ -1,4 +1,4 @@
-from typing import Any, List, Optional
+from typing import List, Optional
import orjson
from django.db import transaction
@@ -23,9 +23,16 @@ def notify_realm_playgrounds(realm: Realm, realm_playgrounds: List[RealmPlaygrou
@transaction.atomic(durable=True)
def do_add_realm_playground(
- realm: Realm, *, acting_user: Optional[UserProfile], **kwargs: Any
+ realm: Realm,
+ *,
+ acting_user: Optional[UserProfile],
+ name: str,
+ pygments_language: str,
+ url_prefix: str,
) -> int:
- realm_playground = RealmPlayground(realm=realm, **kwargs)
+ realm_playground = RealmPlayground(
+ realm=realm, name=name, pygments_language=pygments_language, url_prefix=url_prefix
+ )
# We expect full_clean to always pass since a thorough input validation
# is performed in the view (using check_url, check_pygments_language, etc)
# before calling this function.
diff --git a/zerver/openapi/curl_param_value_generators.py b/zerver/openapi/curl_param_value_generators.py
index b4b892dd773..6f8e0a7affe 100644
--- a/zerver/openapi/curl_param_value_generators.py
+++ b/zerver/openapi/curl_param_value_generators.py
@@ -302,12 +302,13 @@ def add_realm_playground() -> Dict[str, object]:
@openapi_param_value_generator(["/realm/playgrounds/{playground_id}:delete"])
def remove_realm_playground() -> Dict[str, object]:
- playground_info = dict(
+ playground_id = do_add_realm_playground(
+ get_realm("zulip"),
+ acting_user=None,
name="Python playground",
pygments_language="Python",
url_prefix="https://python.example.com",
)
- playground_id = do_add_realm_playground(get_realm("zulip"), acting_user=None, **playground_info)
return {
"playground_id": playground_id,
}
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index 78f9d26ace1..414328a2c61 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -2222,14 +2222,13 @@ class NormalActionsTest(BaseAction):
self.assertEqual(events[0]["domain"], "zulip.org")
def test_realm_playground_events(self) -> None:
- playground_info = dict(
- name="Python playground",
- pygments_language="Python",
- url_prefix="https://python.example.com",
- )
events = self.verify_action(
lambda: do_add_realm_playground(
- self.user_profile.realm, acting_user=None, **playground_info
+ self.user_profile.realm,
+ acting_user=None,
+ name="Python playground",
+ pygments_language="Python",
+ url_prefix="https://python.example.com",
)
)
check_realm_playgrounds("events[0]", events[0])
diff --git a/zerver/tests/test_realm_playgrounds.py b/zerver/tests/test_realm_playgrounds.py
index a082592285d..1ead7ee7c4e 100644
--- a/zerver/tests/test_realm_playgrounds.py
+++ b/zerver/tests/test_realm_playgrounds.py
@@ -94,12 +94,13 @@ class RealmPlaygroundTests(ZulipTestCase):
iago = self.example_user("iago")
realm = get_realm("zulip")
- playground_info = dict(
+ playground_id = do_add_realm_playground(
+ realm,
+ acting_user=iago,
name="Python playground",
pygments_language="Python",
url_prefix="https://python.example.com",
)
- playground_id = do_add_realm_playground(realm, acting_user=iago, **playground_info)
self.assertTrue(RealmPlayground.objects.filter(name="Python playground").exists())
result = self.api_delete(iago, f"/api/v1/realm/playgrounds/{playground_id + 1}")