mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 03:11:54 +00:00
realm_playgrounds: Remove unnecessary Any for kwargs.
Having a more precise type annotation helps with ensuring the migration to use URL templates gets type checked. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
6cb080c447
commit
131729a06c
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user