ruff: Fix B006 Do not use mutable data structures for argument defaults.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
32e0520196
commit
69aaf69d6f
3 changed files with 15 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, Sequence
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from typing_extensions import override
|
from typing_extensions import override
|
||||||
|
@ -78,7 +78,7 @@ class TestGameHandlerBot(BotTestCase, DefaultTests):
|
||||||
self,
|
self,
|
||||||
id: str = "",
|
id: str = "",
|
||||||
bot: Any = None,
|
bot: Any = None,
|
||||||
players: List[str] = ["foo", "baz"],
|
players: Sequence[str] = ["foo", "baz"],
|
||||||
subject: str = "test game",
|
subject: str = "test game",
|
||||||
stream: str = "test",
|
stream: str = "test",
|
||||||
) -> Any:
|
) -> Any:
|
||||||
|
@ -468,8 +468,8 @@ class TestGameHandlerBot(BotTestCase, DefaultTests):
|
||||||
bot = self.add_user_to_cache("foo")
|
bot = self.add_user_to_cache("foo")
|
||||||
self.add_user_to_cache("baz", bot)
|
self.add_user_to_cache("baz", bot)
|
||||||
bot.invites = {"abcdefg": {"host": "foo@example.com", "baz@example.com": "a"}}
|
bot.invites = {"abcdefg": {"host": "foo@example.com", "baz@example.com": "a"}}
|
||||||
self.assertFalse(bot.is_user_not_player("foo@example.com"))
|
self.assertFalse(bot.is_user_not_player("foo@example.com", {}))
|
||||||
self.assertFalse(bot.is_user_not_player("baz@example.com"))
|
self.assertFalse(bot.is_user_not_player("baz@example.com", {}))
|
||||||
|
|
||||||
def test_move_help_message(self) -> None:
|
def test_move_help_message(self) -> None:
|
||||||
bot = self.setup_game()
|
bot = self.setup_game()
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Collection, Dict, List
|
||||||
|
|
||||||
import simple_salesforce
|
import simple_salesforce
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ def get_help_text() -> str:
|
||||||
|
|
||||||
def format_result(
|
def format_result(
|
||||||
result: Dict[str, Any],
|
result: Dict[str, Any],
|
||||||
exclude_keys: List[str] = [],
|
exclude_keys: Collection[str] = [],
|
||||||
force_keys: List[str] = [],
|
force_keys: Collection[str] = [],
|
||||||
rank_output: bool = False,
|
rank_output: bool = False,
|
||||||
show_all_keys: bool = False,
|
show_all_keys: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
exclude_keys += ["Name", "attributes", "Id"]
|
exclude_keys = {*exclude_keys, "Name", "attributes", "Id"}
|
||||||
output = ""
|
output = ""
|
||||||
if result["totalSize"] == 0:
|
if result["totalSize"] == 0:
|
||||||
return "No records found."
|
return "No records found."
|
||||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from typing import Any, Dict, List, Tuple
|
from typing import Any, Dict, Iterable, List, Sequence, Tuple
|
||||||
|
|
||||||
from typing_extensions import override
|
from typing_extensions import override
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ class GameAdapter:
|
||||||
)
|
)
|
||||||
self.start_game_if_ready(game_id)
|
self.start_game_if_ready(game_id)
|
||||||
|
|
||||||
def create_game_lobby(self, message: Dict[str, Any], users: List[str] = []) -> None:
|
def create_game_lobby(self, message: Dict[str, Any], users: Sequence[str] = []) -> None:
|
||||||
if self.is_game_in_subject(message["subject"], message["display_recipient"]):
|
if self.is_game_in_subject(message["subject"], message["display_recipient"]):
|
||||||
self.send_reply(message, "There is already a game in this stream.")
|
self.send_reply(message, "There is already a game in this stream.")
|
||||||
return
|
return
|
||||||
|
@ -499,7 +499,7 @@ class GameAdapter:
|
||||||
reverse=True,
|
reverse=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_invite(self, game_id: str, user_email: str, message: Dict[str, Any] = {}) -> None:
|
def send_invite(self, game_id: str, user_email: str, message: Dict[str, Any]) -> None:
|
||||||
self.invites[game_id].update({user_email.lower(): "p"})
|
self.invites[game_id].update({user_email.lower(): "p"})
|
||||||
self.send_message(user_email, self.alert_new_invitation(game_id), True)
|
self.send_message(user_email, self.alert_new_invitation(game_id), True)
|
||||||
if message != {}:
|
if message != {}:
|
||||||
|
@ -547,7 +547,7 @@ class GameAdapter:
|
||||||
)
|
)
|
||||||
return object
|
return object
|
||||||
|
|
||||||
def join_game(self, game_id: str, user_email: str, message: Dict[str, Any] = {}) -> None:
|
def join_game(self, game_id: str, user_email: str, message: Dict[str, Any]) -> None:
|
||||||
if len(self.get_players(game_id)) >= self.max_players:
|
if len(self.get_players(game_id)) >= self.max_players:
|
||||||
if message != {}:
|
if message != {}:
|
||||||
self.send_reply(message, "This game is full.")
|
self.send_reply(message, "This game is full.")
|
||||||
|
@ -638,7 +638,7 @@ To move subjects, send your message again, otherwise join the game using the lin
|
||||||
self.instances[game_id].handle_message(message["content"], message["sender_email"])
|
self.instances[game_id].handle_message(message["content"], message["sender_email"])
|
||||||
|
|
||||||
def change_game_subject(
|
def change_game_subject(
|
||||||
self, game_id: str, stream_name: str, subject_name: str, message: Dict[str, Any] = {}
|
self, game_id: str, stream_name: str, subject_name: str, message: Dict[str, Any]
|
||||||
) -> None:
|
) -> None:
|
||||||
if self.get_game_instance_by_subject(stream_name, subject_name) is not None:
|
if self.get_game_instance_by_subject(stream_name, subject_name) is not None:
|
||||||
if message != {}:
|
if message != {}:
|
||||||
|
@ -689,7 +689,7 @@ To move subjects, send your message again, otherwise join the game using the lin
|
||||||
self.user_cache = json.loads(user_cache_str)
|
self.user_cache = json.loads(user_cache_str)
|
||||||
return self.user_cache
|
return self.user_cache
|
||||||
|
|
||||||
def verify_users(self, users: List[str], message: Dict[str, Any] = {}) -> List[str]:
|
def verify_users(self, users: Iterable[str], message: Dict[str, Any]) -> List[str]:
|
||||||
verified_users = []
|
verified_users = []
|
||||||
failed = False
|
failed = False
|
||||||
for u in users:
|
for u in users:
|
||||||
|
@ -741,7 +741,7 @@ To move subjects, send your message again, otherwise join the game using the lin
|
||||||
or self.get_game_instance_by_subject(subject_name, stream_name) is not None
|
or self.get_game_instance_by_subject(subject_name, stream_name) is not None
|
||||||
)
|
)
|
||||||
|
|
||||||
def is_user_not_player(self, user_email: str, message: Dict[str, Any] = {}) -> bool:
|
def is_user_not_player(self, user_email: str, message: Dict[str, Any]) -> bool:
|
||||||
user = self.get_user_by_email(user_email)
|
user = self.get_user_by_email(user_email)
|
||||||
if user == {}:
|
if user == {}:
|
||||||
if message != {}:
|
if message != {}:
|
||||||
|
|
Loading…
Add table
Reference in a new issue