mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
ruff: Fix SIM110 Use return any(…) instead of for loop.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
ff1971f5ad
commit
b8b29dc3ad
@@ -65,10 +65,10 @@ def process_user(
|
|||||||
def is_team_admin(user_dict: Dict[str, Any]) -> bool:
|
def is_team_admin(user_dict: Dict[str, Any]) -> bool:
|
||||||
if user_dict["teams"] is None:
|
if user_dict["teams"] is None:
|
||||||
return False
|
return False
|
||||||
for team in user_dict["teams"]:
|
return any(
|
||||||
if team["name"] == team_name and "team_admin" in team["roles"]:
|
team["name"] == team_name and "team_admin" in team["roles"]
|
||||||
return True
|
for team in user_dict["teams"]
|
||||||
return False
|
)
|
||||||
|
|
||||||
def get_full_name(user_dict: Dict[str, Any]) -> str:
|
def get_full_name(user_dict: Dict[str, Any]) -> str:
|
||||||
full_name = "{} {}".format(user_dict["first_name"], user_dict["last_name"])
|
full_name = "{} {}".format(user_dict["first_name"], user_dict["last_name"])
|
||||||
@@ -809,10 +809,7 @@ def check_user_in_team(user: Dict[str, Any], team_name: str) -> bool:
|
|||||||
if user["teams"] is None:
|
if user["teams"] is None:
|
||||||
# This is null for users not on any team
|
# This is null for users not on any team
|
||||||
return False
|
return False
|
||||||
for team in user["teams"]:
|
return any(team["name"] == team_name for team in user["teams"])
|
||||||
if team["name"] == team_name:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def label_mirror_dummy_users(
|
def label_mirror_dummy_users(
|
||||||
|
|||||||
@@ -768,10 +768,7 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
|
|||||||
if parsed_url.netloc == "pasteboard.co":
|
if parsed_url.netloc == "pasteboard.co":
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for ext in IMAGE_EXTENSIONS:
|
return any(parsed_url.path.lower().endswith(ext) for ext in IMAGE_EXTENSIONS)
|
||||||
if parsed_url.path.lower().endswith(ext):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def corrected_image_source(self, url: str) -> Optional[str]:
|
def corrected_image_source(self, url: str) -> Optional[str]:
|
||||||
# This function adjusts any URLs from linx.li and
|
# This function adjusts any URLs from linx.li and
|
||||||
|
|||||||
@@ -121,17 +121,14 @@ def is_web_public_narrow(narrow: Optional[Iterable[Dict[str, Any]]]) -> bool:
|
|||||||
if narrow is None:
|
if narrow is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for term in narrow:
|
return any(
|
||||||
# Web-public queries are only allowed for limited types of narrows.
|
# Web-public queries are only allowed for limited types of narrows.
|
||||||
# term == {'operator': 'streams', 'operand': 'web-public', 'negated': False}
|
# term == {'operator': 'streams', 'operand': 'web-public', 'negated': False}
|
||||||
if (
|
term["operator"] == "streams"
|
||||||
term["operator"] == "streams"
|
and term["operand"] == "web-public"
|
||||||
and term["operand"] == "web-public"
|
and term["negated"] is False
|
||||||
and term["negated"] is False
|
for term in narrow
|
||||||
):
|
)
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def build_narrow_filter(narrow: Collection[Sequence[str]]) -> Callable[[Mapping[str, Any]], bool]:
|
def build_narrow_filter(narrow: Collection[Sequence[str]]) -> Callable[[Mapping[str, Any]], bool]:
|
||||||
|
|||||||
Reference in New Issue
Block a user