Skip to content

Commit 059458b

Browse files
committed
python: Fix PAR001 Redundant parentheses.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent aeb89bc commit 059458b

File tree

21 files changed

+29
-41
lines changed

21 files changed

+29
-41
lines changed

tools/custom_check.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@
3636
"good_lines": ["def foo (self):"],
3737
"bad_lines": ["def foo(self: Any):"],
3838
},
39-
# This next check could have false positives, but it seems pretty
40-
# rare; if we find any, they can be added to the exclude list for
41-
# this rule.
42-
{
43-
"pattern": r" % [a-zA-Z0-9_.]*\)?$",
44-
"description": "Used % comprehension without a tuple",
45-
},
46-
{
47-
"pattern": r".*%s.* % \([a-zA-Z0-9_.]*\)$",
48-
"description": "Used % comprehension without a tuple",
49-
},
5039
{
5140
"pattern": r"__future__",
5241
"include_only": {"zulip_bots/zulip_bots/bots/"},

tools/provision

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ the Python version this command is executed with."""
4343
py_version = tuple(int(num) for num in py_version_list[0:2])
4444
venv_name = f"zulip-api-py{py_version[0]}-venv"
4545

46-
if py_version <= (3, 1) and (not options.force):
46+
if py_version <= (3, 1) and not options.force:
4747
print(
4848
red
4949
+ "Provision failed: Cannot create venv with outdated Python version ({}).\n"

zulip/integrations/bridge_with_irc/irc_mirror_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def forward_to_irc(msg: Dict[str, Any]) -> None:
7575
in_the_specified_stream = msg["display_recipient"] == self.stream
7676
at_the_specified_subject = msg["subject"].casefold() == self.topic.casefold()
7777
if in_the_specified_stream and at_the_specified_subject:
78-
msg["content"] = ("@**{}**: ".format(msg["sender_full_name"])) + msg["content"]
78+
msg["content"] = "@**{}**: ".format(msg["sender_full_name"]) + msg["content"]
7979
send = lambda x: self.c.privmsg(self.channel, x)
8080
else:
8181
return

zulip/integrations/google/google-calendar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ parser.add_argument(
8282

8383
options = parser.parse_args()
8484

85-
if not (options.zulip_email):
85+
if not options.zulip_email:
8686
parser.error("You must specify --user")
8787

8888
zulip_client = zulip.init_from_options(options)

zulip/integrations/rss/rss-bot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,15 @@ for feed_url in feed_urls:
227227
)
228228
if (
229229
entry_time is not None
230-
and (time.time() - calendar.timegm(entry_time)) > OLDNESS_THRESHOLD * 60 * 60 * 24
230+
and time.time() - calendar.timegm(entry_time) > OLDNESS_THRESHOLD * 60 * 60 * 24
231231
):
232232
# As a safeguard against misbehaving feeds, don't try to process
233233
# entries older than some threshold.
234234
continue
235235
if entry_hash in old_feed_hashes:
236236
# We've already seen this. No need to process any older entries.
237237
break
238-
if (not old_feed_hashes) and (len(new_hashes) >= 3):
238+
if not old_feed_hashes and len(new_hashes) >= 3:
239239
# On a first run, pick up the 3 most recent entries. An RSS feed has
240240
# entries in reverse chronological order.
241241
break

zulip/integrations/trello/zulip_trello.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def main() -> None:
122122
parser.add_argument(
123123
"--trello-board-id",
124124
required=True,
125-
help=("The Trello board short ID. Can usually be found in the URL of the Trello board."),
125+
help="The Trello board short ID. Can usually be found in the URL of the Trello board.",
126126
)
127127
parser.add_argument(
128128
"--trello-api-key",

zulip/integrations/zephyr/zephyr_mirror_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def process_notice(
474474
# Drop messages not to the listed subscriptions
475475
if is_personal and not options.forward_personals:
476476
return
477-
if (zephyr_class.lower() not in current_zephyr_subs) and not is_personal:
477+
if zephyr_class.lower() not in current_zephyr_subs and not is_personal:
478478
logger.debug("Skipping ... %s/%s/%s", zephyr_class, zephyr_instance, is_personal)
479479
return
480480
if notice.z_default_format.startswith(b"Zephyr error: See") or notice.z_default_format.endswith(
@@ -916,7 +916,7 @@ def maybe_forward_to_zephyr(message: Dict[str, Any], zulip_client: zulip.Client)
916916
# The key string can be used to direct any type of text.
917917
if message["sender_email"] == zulip_account_email:
918918
if not (
919-
(message["type"] == "stream")
919+
message["type"] == "stream"
920920
or (
921921
message["type"] == "private"
922922
and False

zulip/zulip/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def send_message(recipients: List[str], stream: str, subject: str, message: str)
6060
if len(recipients) != 0 and has_stream:
6161
click.echo("You cannot specify both a username and a stream/subject.")
6262
raise SystemExit(1)
63-
if len(recipients) == 0 and (has_stream != has_subject):
63+
if len(recipients) == 0 and has_stream != has_subject:
6464
click.echo("Stream messages must have a subject")
6565
raise SystemExit(1)
6666
if len(recipients) == 0 and not has_stream:

zulip/zulip/send.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def main() -> int:
7777
# Sanity check user data
7878
if len(options.recipients) != 0 and (options.stream or options.subject):
7979
parser.error("You cannot specify both a username and a stream/subject.")
80-
if len(options.recipients) == 0 and (bool(options.stream) != bool(options.subject)):
80+
if len(options.recipients) == 0 and bool(options.stream) != bool(options.subject):
8181
parser.error("Stream messages must have a subject")
8282
if len(options.recipients) == 0 and not (options.stream and options.subject):
8383
parser.error("You must specify a stream/subject or at least one recipient.")

zulip_bots/zulip_bots/bots/chessbot/chessbot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def make_loss_response(board: chess.Board, reason: str) -> str:
401401
402402
Returns: The loss response string.
403403
"""
404-
return ("*{}* {}. **{}** wins!\n\n{}").format(
404+
return "*{}* {}. **{}** wins!\n\n{}".format(
405405
"White" if board.turn else "Black",
406406
reason,
407407
"Black" if board.turn else "White",
@@ -418,7 +418,7 @@ def make_not_legal_response(board: chess.Board, move_san: str) -> str:
418418
419419
Returns: The not-legal-move response string.
420420
"""
421-
return ("Sorry, the move *{}* isn't legal.\n\n{}\n\n\n{}").format(
421+
return "Sorry, the move *{}* isn't legal.\n\n{}\n\n\n{}".format(
422422
move_san, make_str(board, board.turn), make_footer()
423423
)
424424

0 commit comments

Comments
 (0)