Skip to content

Commit e6dcdbc

Browse files
noirbizarreLee-W
authored andcommitted
style: fix formatting for ruff>=0.9
1 parent 646a9df commit e6dcdbc

12 files changed

+27
-33
lines changed

commitizen/cli.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ def __call__(
7171
{
7272
"name": ["--template", "-t"],
7373
"help": (
74-
"changelog template file name "
75-
"(relative to the current working directory)"
74+
"changelog template file name (relative to the current working directory)"
7675
),
7776
},
7877
{

commitizen/commands/bump.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def __call__(self) -> None: # noqa: C901
252252
# Unless we previously had a prerelease.
253253
if not commits and not current_version.is_prerelease:
254254
raise NoCommitsFoundError(
255-
"[NO_COMMITS_FOUND]\n" "No new commits found."
255+
"[NO_COMMITS_FOUND]\nNo new commits found."
256256
)
257257

258258
increment = self.find_increment(commits)
@@ -296,7 +296,7 @@ def __call__(self) -> None: # noqa: C901
296296
raise GetNextExit()
297297

298298
# Report found information
299-
information = f"{message}\n" f"tag to create: {new_tag_version}\n"
299+
information = f"{message}\ntag to create: {new_tag_version}\n"
300300
if increment:
301301
information += f"increment detected: {increment}\n"
302302

@@ -310,8 +310,7 @@ def __call__(self) -> None: # noqa: C901
310310

311311
if increment is None and new_tag_version == current_tag_version:
312312
raise NoneIncrementExit(
313-
"[NO_COMMITS_TO_BUMP]\n"
314-
"The commits found are not eligible to be bumped"
313+
"[NO_COMMITS_TO_BUMP]\nThe commits found are not eligible to be bumped"
315314
)
316315

317316
files: list[str] = []

commitizen/cz/conventional_commits/conventional_commits.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ def questions(self) -> Questions:
8686
},
8787
{
8888
"value": "test",
89-
"name": (
90-
"test: Adding missing or correcting " "existing tests"
91-
),
89+
"name": ("test: Adding missing or correcting existing tests"),
9290
"key": "t",
9391
},
9492
{

tests/commands/test_bump_command.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_bump_minor_increment_annotated_config_file(
102102
):
103103
tmp_commitizen_cfg_file = tmp_commitizen_project.join("pyproject.toml")
104104
tmp_commitizen_cfg_file.write(
105-
f"{tmp_commitizen_cfg_file.read()}\n" f"annotated_tag = 1"
105+
f"{tmp_commitizen_cfg_file.read()}\nannotated_tag = 1"
106106
)
107107
create_file_and_commit(commit_msg)
108108
testargs = ["cz", "bump", "--yes"]
@@ -121,7 +121,7 @@ def test_bump_minor_increment_signed_config_file(
121121
commit_msg, mocker: MockFixture, tmp_commitizen_project_with_gpg
122122
):
123123
tmp_commitizen_cfg_file = tmp_commitizen_project_with_gpg.join("pyproject.toml")
124-
tmp_commitizen_cfg_file.write(f"{tmp_commitizen_cfg_file.read()}\n" f"gpg_sign = 1")
124+
tmp_commitizen_cfg_file.write(f"{tmp_commitizen_cfg_file.read()}\ngpg_sign = 1")
125125
create_file_and_commit(commit_msg)
126126
testargs = ["cz", "bump", "--yes"]
127127
mocker.patch.object(sys, "argv", testargs)
@@ -383,7 +383,7 @@ def test_bump_on_git_with_hooks_no_verify_disabled(mocker: MockFixture):
383383
"""Bump commit without --no-verify"""
384384
cmd.run("mkdir .git/hooks")
385385
with open(".git/hooks/pre-commit", "w", encoding="utf-8") as f:
386-
f.write("#!/usr/bin/env bash\n" 'echo "0.1.0"')
386+
f.write('#!/usr/bin/env bash\necho "0.1.0"')
387387
cmd.run("chmod +x .git/hooks/pre-commit")
388388

389389
# MINOR
@@ -402,7 +402,7 @@ def test_bump_on_git_with_hooks_no_verify_disabled(mocker: MockFixture):
402402
def test_bump_tag_exists_raises_exception(mocker: MockFixture):
403403
cmd.run("mkdir .git/hooks")
404404
with open(".git/hooks/post-commit", "w", encoding="utf-8") as f:
405-
f.write("#!/usr/bin/env bash\n" "exit 9")
405+
f.write("#!/usr/bin/env bash\nexit 9")
406406
cmd.run("chmod +x .git/hooks/post-commit")
407407

408408
# MINOR
@@ -421,7 +421,7 @@ def test_bump_tag_exists_raises_exception(mocker: MockFixture):
421421
def test_bump_on_git_with_hooks_no_verify_enabled(mocker: MockFixture):
422422
cmd.run("mkdir .git/hooks")
423423
with open(".git/hooks/pre-commit", "w", encoding="utf-8") as f:
424-
f.write("#!/usr/bin/env bash\n" 'echo "0.1.0"')
424+
f.write('#!/usr/bin/env bash\necho "0.1.0"')
425425
cmd.run("chmod +x .git/hooks/pre-commit")
426426

427427
# MINOR
@@ -478,7 +478,7 @@ def test_bump_when_no_new_commit(mocker: MockFixture):
478478
with pytest.raises(NoCommitsFoundError) as excinfo:
479479
cli.main()
480480

481-
expected_error_message = "[NO_COMMITS_FOUND]\n" "No new commits found."
481+
expected_error_message = "[NO_COMMITS_FOUND]\nNo new commits found."
482482
assert expected_error_message in str(excinfo.value)
483483

484484

@@ -710,7 +710,7 @@ def test_prevent_prerelease_when_no_increment_detected(mocker: MockFixture, caps
710710
cli.main()
711711

712712
expected_error_message = (
713-
"[NO_COMMITS_FOUND]\n" "No commits found to generate a pre-release."
713+
"[NO_COMMITS_FOUND]\nNo commits found to generate a pre-release."
714714
)
715715
assert expected_error_message in str(excinfo.value)
716716

@@ -862,7 +862,7 @@ def test_bump_changelog_command_commits_untracked_changelog_and_version_files(
862862
mode="a",
863863
encoding="utf-8",
864864
) as commitizen_config:
865-
commitizen_config.write(f"version_files = [\n" f"'{version_regex}'\n]")
865+
commitizen_config.write(f"version_files = [\n'{version_regex}'\n]")
866866

867867
with tmp_commitizen_project.join(version_filepath).open(
868868
mode="a+", encoding="utf-8"
@@ -917,7 +917,7 @@ def test_bump_invalid_manual_version_raises_exception(mocker, manual_version):
917917
cli.main()
918918

919919
expected_error_message = (
920-
"[INVALID_MANUAL_VERSION]\n" f"Invalid manual version: '{manual_version}'"
920+
f"[INVALID_MANUAL_VERSION]\nInvalid manual version: '{manual_version}'"
921921
)
922922
assert expected_error_message in str(excinfo.value)
923923

@@ -1425,7 +1425,7 @@ def test_bump_changelog_contains_increment_only(mocker, tmp_commitizen_project,
14251425
project_root = Path(tmp_commitizen_project)
14261426
tmp_commitizen_cfg_file = project_root / "pyproject.toml"
14271427
tmp_commitizen_cfg_file.write_text(
1428-
"[tool.commitizen]\n" 'version="1.0.0"\n' "update_changelog_on_bump = true\n"
1428+
'[tool.commitizen]\nversion="1.0.0"\nupdate_changelog_on_bump = true\n'
14291429
)
14301430
tmp_changelog_file = project_root / "CHANGELOG.md"
14311431
tmp_changelog_file.write_text("## v1.0.0")

tests/commands/test_changelog_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ def test_changelog_prerelease_rev_with_use_scheme_semver(
12951295
mocker.patch("commitizen.git.GitTag.date", "2022-02-13")
12961296

12971297
with open(config_path, "a") as f:
1298-
f.write('tag_format = "$version"\n' 'version_scheme = "semver"')
1298+
f.write('tag_format = "$version"\nversion_scheme = "semver"')
12991299

13001300
# create commit and tag
13011301
create_file_and_commit("feat: new file")

tests/commands/test_check_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def test_check_a_range_of_failed_git_commits(config, mocker: MockFixture):
238238
ill_formated_commits_msgs = [
239239
"First commit does not follow rule",
240240
"Second commit does not follow rule",
241-
("Third commit does not follow rule\n" "Ill-formatted commit with body"),
241+
("Third commit does not follow rule\nIll-formatted commit with body"),
242242
]
243243
mocker.patch(
244244
"commitizen.git.get_commits",

tests/commands/test_version_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_version_for_showing_both_versions(config, capsys):
6161
)()
6262
captured = capsys.readouterr()
6363
expected_out = (
64-
f"Installed Commitizen Version: {__version__}\n" f"Project Version: v0.0.1"
64+
f"Installed Commitizen Version: {__version__}\nProject Version: v0.0.1"
6565
)
6666
assert expected_out in captured.out
6767

tests/conftest.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def tmp_git_project(tmpdir):
6969
@pytest.fixture(scope="function")
7070
def tmp_commitizen_project(tmp_git_project):
7171
tmp_commitizen_cfg_file = tmp_git_project.join("pyproject.toml")
72-
tmp_commitizen_cfg_file.write("[tool.commitizen]\n" 'version="0.1.0"\n')
72+
tmp_commitizen_cfg_file.write('[tool.commitizen]\nversion="0.1.0"\n')
7373

7474
yield tmp_git_project
7575

@@ -83,9 +83,7 @@ def _initial(
8383
):
8484
with tmp_git_project.as_cwd():
8585
tmp_commitizen_cfg_file = tmp_git_project.join("pyproject.toml")
86-
tmp_commitizen_cfg_file.write(
87-
f"[tool.commitizen]\n" f'version="{version}"\n'
88-
)
86+
tmp_commitizen_cfg_file.write(f'[tool.commitizen]\nversion="{version}"\n')
8987
tmp_version_file = tmp_git_project.join("__version__.py")
9088
tmp_version_file.write(version)
9189
tmp_commitizen_cfg_file = tmp_git_project.join("pyproject.toml")
@@ -251,7 +249,7 @@ def changelog_format(
251249
if "tmp_commitizen_project" in request.fixturenames:
252250
tmp_commitizen_project = request.getfixturevalue("tmp_commitizen_project")
253251
pyproject = tmp_commitizen_project / "pyproject.toml"
254-
pyproject.write(f"{pyproject.read()}\n" f'changelog_format = "{format}"\n')
252+
pyproject.write(f'{pyproject.read()}\nchangelog_format = "{format}"\n')
255253
return get_changelog_format(config)
256254

257255

tests/test_changelog.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1413,9 +1413,9 @@ def changelog_message_builder_hook(message: dict, commit: git.GitCommit):
14131413
for no, line in enumerate(result.splitlines()):
14141414
if (line := line.strip()) and (match := RE_HEADER.match(line)):
14151415
change_type = match.group("type")
1416-
assert (
1417-
change_type == "overridden"
1418-
), f"Line {no}: type {change_type} should have been overridden"
1416+
assert change_type == "overridden", (
1417+
f"Line {no}: type {change_type} should have been overridden"
1418+
)
14191419

14201420

14211421
def test_render_changelog_with_changelog_release_hook(

tests/test_conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def test_init_empty_config_content(self, tmpdir, config_file, exception_string):
235235
def test_init_empty_config_content_with_existing_content(
236236
self, tmpdir, config_file, exception_string
237237
):
238-
existing_content = "[tool.black]\n" "line-length = 88\n"
238+
existing_content = "[tool.black]\nline-length = 88\n"
239239

240240
path = tmpdir.mkdir("commitizen").join(config_file)
241241
path.write(existing_content)

tests/test_cz_conventional_commits.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
)
88
from commitizen.cz.exceptions import AnswerRequiredError
99

10-
valid_scopes = ["", "simple", "dash-separated", "camelCase" "UPPERCASE"]
10+
valid_scopes = ["", "simple", "dash-separated", "camelCaseUPPERCASE"]
1111

1212
scopes_transformations = [["with spaces", "with-spaces"], [None, ""]]
1313

tests/test_git.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def test_get_reachable_tags_with_commits(
8484

8585

8686
def test_get_tag_names(mocker: MockFixture):
87-
tag_str = "v1.0.0\n" "v0.5.0\n" "v0.0.1\n"
87+
tag_str = "v1.0.0\nv0.5.0\nv0.0.1\n"
8888
mocker.patch("commitizen.cmd.run", return_value=FakeCommand(out=tag_str))
8989

9090
assert git.get_tag_names() == ["v1.0.0", "v0.5.0", "v0.0.1"]

0 commit comments

Comments
 (0)