Skip to content

Commit a49add3

Browse files
committed
lint: Replace Black with Ruff.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 2a0eff6 commit a49add3

File tree

15 files changed

+31
-64
lines changed

15 files changed

+31
-64
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,5 @@ src = [
110110
"zulip_bots",
111111
"zulip_botserver",
112112
]
113+
target-version = "py38"
113114
line-length = 100

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
crayons
22
twine
3-
black~=23.10.1
43
mock
54
pytest
65
pytest-cov

tools/deploy

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ def pack(options: argparse.Namespace) -> None:
5959
[deploy]
6060
bot={}
6161
zuliprc=zuliprc
62-
""".format(
63-
options.main
64-
)
62+
""".format(options.main)
6563
)
6664
zip_file.writestr("config.ini", bot_config)
6765
zip_file.close()

tools/lint

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#! /usr/bin/env python3
22

33
import argparse
4-
import re
54
import sys
65

76
from zulint.command import LinterConfig, add_default_linter_arguments
@@ -36,16 +35,14 @@ def run() -> None:
3635
"ruff", ["ruff", "check", "--quiet"], ["py"], fix_arg="--fix", description="Python linter"
3736
)
3837
linter_config.external_linter(
39-
"gitlint", ["tools/lint-commits"], description="Git Lint for commit messages"
38+
"ruff-format",
39+
["ruff", "format", "--quiet"],
40+
["py"],
41+
check_arg="--check",
42+
description="Python formatter",
4043
)
4144
linter_config.external_linter(
42-
"black",
43-
["black"],
44-
["py"],
45-
description="Reformats Python code",
46-
check_arg=["--check"],
47-
suppress_line=lambda line: line == "All done! ✨ 🍰 ✨\n"
48-
or re.fullmatch(r"\d+ files? would be left unchanged\.\n", line) is not None,
45+
"gitlint", ["tools/lint-commits"], description="Git Lint for commit messages"
4946
)
5047

5148
@linter_config.lint

tools/provision

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ the Python version this command is executed with."""
4545

4646
if py_version <= (3, 1) and (not options.force):
4747
print(
48-
red + "Provision failed: Cannot create venv with outdated Python version ({}).\n"
49-
"Maybe try `python3 tools/provision`.".format(py_version_output.strip()) + end_format
48+
red
49+
+ "Provision failed: Cannot create venv with outdated Python version ({}).\n"
50+
"Maybe try `python3 tools/provision`.".format(py_version_output.strip())
51+
+ end_format
5052
)
5153
sys.exit(1)
5254

zulip/integrations/jabber/jabber_mirror_backend.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,7 @@ def config_error(msg: str) -> None:
301301
zulip configuration file under the jabber_mirror section (exceptions are noted
302302
in their help sections). Keys have the same name as options with hyphens
303303
replaced with underscores. Zulip configuration options go in the api section,
304-
as normal.""".replace(
305-
"\n", " "
306-
)
304+
as normal.""".replace("\n", " ")
307305
)
308306
parser.add_option(
309307
"--mode",
@@ -314,9 +312,7 @@ def config_error(msg: str) -> None:
314312
all messages they send on Zulip to Jabber and all private Jabber messages to
315313
Zulip. In "public" mode, the mirror uses the credentials for a dedicated mirror
316314
user and mirrors messages sent to Jabber rooms to Zulip. Defaults to
317-
"personal"'''.replace(
318-
"\n", " "
319-
),
315+
"personal"'''.replace("\n", " "),
320316
)
321317
parser.add_option(
322318
"--zulip-email-suffix",
@@ -327,9 +323,7 @@ def config_error(msg: str) -> None:
327323
suffix before sending requests to the Jabber server. For example, specifying
328324
"+foo" will cause messages that are sent to the "bar" room by nickname "qux" to
329325
be mirrored to the "bar/xmpp" stream in Zulip by user "[email protected]". This
330-
option does not affect login credentials.""".replace(
331-
"\n", " "
332-
),
326+
option does not affect login credentials.""".replace("\n", " "),
333327
)
334328
parser.add_option(
335329
"-d",

zulip/integrations/perforce/zulip_change-commit.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@
8484
```quote
8585
{desc}
8686
```
87-
""".format(
88-
user=metadata["user"], change=change, path=changeroot, desc=metadata["desc"]
89-
)
87+
""".format(user=metadata["user"], change=change, path=changeroot, desc=metadata["desc"])
9088

9189
message_data: Dict[str, Any] = {
9290
"type": "stream",

zulip/tests/test_default_arguments.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ def test_config_path_with_tilde(self, mock_os_path_exists: bool) -> None:
4141
expanded_test_path = os.path.abspath(os.path.expanduser(test_path))
4242
self.assertEqual(
4343
str(cm.exception),
44-
"api_key or email not specified and "
45-
"file {} does not exist".format(expanded_test_path),
44+
"api_key or email not specified and " "file {} does not exist".format(
45+
expanded_test_path
46+
),
4647
)
4748

4849

zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ def test_invalid_when_handle_message(self) -> None:
7979
{"auth_token": "someInvalidKey", "username": "aaron", "goalname": "goal"}
8080
), patch("requests.get", side_effect=ConnectionError()), self.mock_http_conversation(
8181
"test_invalid_when_handle_message"
82-
), patch(
83-
"logging.exception"
84-
):
82+
), patch("logging.exception"):
8583
self.verify_reply("5", "Error. Check your key!")
8684

8785
def test_error(self) -> None:

zulip_bots/zulip_bots/bots/chessbot/chessbot.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def handle_message(self, message: Dict[str, str], bot_handler: BotHandler) -> No
5454
if bot_handler.storage.contains("is_with_computer"):
5555
is_with_computer = (
5656
# `bot_handler`'s `storage` only accepts `str` values.
57-
bot_handler.storage.get("is_with_computer")
58-
== str(True)
57+
bot_handler.storage.get("is_with_computer") == str(True)
5958
)
6059

6160
if bot_handler.storage.contains("last_fen"):

0 commit comments

Comments
 (0)