Skip to content

Commit c9d8ece

Browse files
test: enable ruff rule PT (#1837)
* test: enable ruff rule PT006 and PT007 It turns out that I just had to run uv run ruff check --fix --unsafe-fixes * test: enable PT011 * test: enable PT022 * test: nit
1 parent a6db54c commit c9d8ece

32 files changed

+169
-160
lines changed

pyproject.toml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,7 @@ select = [
235235
"TC005",
236236
"TC006",
237237
]
238-
ignore = [
239-
"E501",
240-
"D1",
241-
"D415",
242-
"PT006", # TODO(bearomorphism): enable this rule
243-
"PT007", # TODO(bearomorphism): enable this rule
244-
"PT011", # TODO(bearomorphism): enable this rule
245-
"PT022", # TODO(bearomorphism): enable this rule
246-
]
238+
ignore = ["E501", "D1", "D415"]
247239
extend-safe-fixes = [
248240
"TC", # Move imports inside/outside TYPE_CHECKING blocks
249241
"UP", # Update syntaxes for current Python version recommendations

tests/commands/test_bump_command.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040

4141
@pytest.mark.parametrize(
4242
"commit_msg",
43-
(
43+
[
4444
"fix: username exception",
4545
"fix(user): username exception",
4646
"refactor: remove ini configuration support",
4747
"refactor(config): remove ini configuration support",
4848
"perf: update to use multiprocess",
4949
"perf(worker): update to use multiprocess",
50-
),
50+
],
5151
)
5252
@pytest.mark.usefixtures("tmp_commitizen_project")
5353
def test_bump_patch_increment(commit_msg: str, util: UtilFixture):
@@ -56,7 +56,7 @@ def test_bump_patch_increment(commit_msg: str, util: UtilFixture):
5656
assert git.tag_exist("0.1.1") is True
5757

5858

59-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
59+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
6060
@pytest.mark.usefixtures("tmp_commitizen_project")
6161
def test_bump_minor_increment(commit_msg: str, util: UtilFixture):
6262
util.create_file_and_commit(commit_msg)
@@ -68,7 +68,7 @@ def test_bump_minor_increment(commit_msg: str, util: UtilFixture):
6868
)
6969

7070

71-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
71+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
7272
@pytest.mark.usefixtures("tmp_commitizen_project")
7373
def test_bump_minor_increment_annotated(commit_msg: str, util: UtilFixture):
7474
util.create_file_and_commit(commit_msg)
@@ -82,7 +82,7 @@ def test_bump_minor_increment_annotated(commit_msg: str, util: UtilFixture):
8282
assert git.is_signed_tag("0.2.0") is False
8383

8484

85-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
85+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
8686
@pytest.mark.usefixtures("tmp_commitizen_project_with_gpg")
8787
def test_bump_minor_increment_signed(commit_msg: str, util: UtilFixture):
8888
util.create_file_and_commit(commit_msg)
@@ -96,7 +96,7 @@ def test_bump_minor_increment_signed(commit_msg: str, util: UtilFixture):
9696
assert git.is_signed_tag("0.2.0") is True
9797

9898

99-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
99+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
100100
def test_bump_minor_increment_annotated_config_file(
101101
commit_msg: str, util: UtilFixture, pyproject: Path
102102
):
@@ -112,7 +112,7 @@ def test_bump_minor_increment_annotated_config_file(
112112
assert git.is_signed_tag("0.2.0") is False
113113

114114

115-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
115+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
116116
def test_bump_minor_increment_signed_config_file(
117117
commit_msg: str, util: UtilFixture, tmp_commitizen_project_with_gpg
118118
):
@@ -132,7 +132,7 @@ def test_bump_minor_increment_signed_config_file(
132132
@pytest.mark.usefixtures("tmp_commitizen_project")
133133
@pytest.mark.parametrize(
134134
"commit_msg",
135-
(
135+
[
136136
"feat: new user interface\n\nBREAKING CHANGE: age is no longer supported",
137137
"feat!: new user interface\n\nBREAKING CHANGE: age is no longer supported",
138138
"feat!: new user interface",
@@ -141,7 +141,7 @@ def test_bump_minor_increment_signed_config_file(
141141
"feat(user)!: new user interface",
142142
"BREAKING CHANGE: age is no longer supported",
143143
"BREAKING-CHANGE: age is no longer supported",
144-
),
144+
],
145145
)
146146
def test_bump_major_increment(commit_msg: str, util: UtilFixture):
147147
util.create_file_and_commit(commit_msg)
@@ -152,7 +152,7 @@ def test_bump_major_increment(commit_msg: str, util: UtilFixture):
152152
@pytest.mark.usefixtures("tmp_commitizen_project")
153153
@pytest.mark.parametrize(
154154
"commit_msg",
155-
(
155+
[
156156
"feat: new user interface\n\nBREAKING CHANGE: age is no longer supported",
157157
"feat!: new user interface\n\nBREAKING CHANGE: age is no longer supported",
158158
"feat!: new user interface",
@@ -161,7 +161,7 @@ def test_bump_major_increment(commit_msg: str, util: UtilFixture):
161161
"feat(user)!: new user interface",
162162
"BREAKING CHANGE: age is no longer supported",
163163
"BREAKING-CHANGE: age is no longer supported",
164-
),
164+
],
165165
)
166166
def test_bump_major_increment_major_version_zero(commit_msg: str, util: UtilFixture):
167167
util.create_file_and_commit(commit_msg)
@@ -171,7 +171,7 @@ def test_bump_major_increment_major_version_zero(commit_msg: str, util: UtilFixt
171171

172172
@pytest.mark.usefixtures("tmp_commitizen_project")
173173
@pytest.mark.parametrize(
174-
"commit_msg,increment,expected_tag",
174+
("commit_msg", "increment", "expected_tag"),
175175
[
176176
("feat: new file", "PATCH", "0.1.1"),
177177
("fix: username exception", "major", "1.0.0"),
@@ -607,7 +607,7 @@ def test_bump_with_git_to_stdout_arg(util: UtilFixture, capsys: pytest.CaptureFi
607607

608608

609609
@pytest.mark.parametrize(
610-
"version_filepath, version_regex, version_file_content",
610+
("version_filepath", "version_regex", "version_file_content"),
611611
[
612612
pytest.param(
613613
"pyproject.toml",
@@ -779,7 +779,7 @@ def test_bump_manual_version_disallows_major_version_zero(util: UtilFixture):
779779

780780

781781
@pytest.mark.parametrize(
782-
"initial_version, expected_version_after_bump",
782+
("initial_version", "expected_version_after_bump"),
783783
[
784784
("1", "1.1.0"),
785785
("1.2", "1.3.0"),
@@ -804,7 +804,7 @@ def test_bump_version_with_less_components_in_config(
804804
assert expected_version_after_bump in f.read()
805805

806806

807-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
807+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
808808
def test_bump_with_pre_bump_hooks(
809809
commit_msg, mocker: MockFixture, tmp_commitizen_project, util: UtilFixture
810810
):
@@ -992,7 +992,7 @@ def test_bump_command_prerelease_scheme_check_old_tags(
992992
@pytest.mark.usefixtures("tmp_commitizen_project")
993993
@pytest.mark.usefixtures("use_cz_semver")
994994
@pytest.mark.parametrize(
995-
"message, expected_tag",
995+
("message", "expected_tag"),
996996
[
997997
("minor: add users", "0.2.0"),
998998
("patch: bug affecting users", "0.1.1"),
@@ -1008,7 +1008,7 @@ def test_bump_with_plugin(util: UtilFixture, message: str, expected_tag: str):
10081008
@pytest.mark.usefixtures("tmp_commitizen_project")
10091009
@pytest.mark.usefixtures("use_cz_semver")
10101010
@pytest.mark.parametrize(
1011-
"message, expected_tag",
1011+
("message", "expected_tag"),
10121012
[
10131013
("minor: add users", "0.2.0"),
10141014
("patch: bug affecting users", "0.1.1"),
@@ -1060,14 +1060,14 @@ def test_bump_command_version_scheme_priority_over_version_type(util: UtilFixtur
10601060

10611061

10621062
@pytest.mark.parametrize(
1063-
"arg, cfg, expected",
1064-
(
1063+
("arg", "cfg", "expected"),
1064+
[
10651065
pytest.param("", "", "default", id="default"),
10661066
pytest.param("", "changelog.cfg", "from config", id="from-config"),
10671067
pytest.param(
10681068
"--template=changelog.cmd", "changelog.cfg", "from cmd", id="from-command"
10691069
),
1070-
),
1070+
],
10711071
)
10721072
def test_bump_template_option_precedence(
10731073
tmp_commitizen_project: Path,

tests/commands/test_changelog_command.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def test_changelog_incremental_with_release_candidate_version(
692692

693693

694694
@pytest.mark.parametrize(
695-
"from_pre,to_pre", itertools.product(["alpha", "beta", "rc"], repeat=2)
695+
("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
696696
)
697697
@pytest.mark.usefixtures("tmp_commitizen_project")
698698
@pytest.mark.freeze_time("2021-06-11")
@@ -856,13 +856,13 @@ def test_changelog_from_rev_latest_version_from_arg(
856856

857857
@pytest.mark.usefixtures("tmp_commitizen_project")
858858
@pytest.mark.parametrize(
859-
"rev_range,tag",
860-
(
859+
("rev_range", "tag"),
860+
[
861861
pytest.param("0.8.0", "0.2.0", id="single-not-found"),
862862
pytest.param("0.1.0..0.3.0", "0.3.0", id="lower-bound-not-found"),
863863
pytest.param("0.1.0..0.3.0", "0.1.0", id="upper-bound-not-found"),
864864
pytest.param("0.3.0..0.4.0", "0.2.0", id="none-found"),
865-
),
865+
],
866866
)
867867
def test_changelog_from_rev_range_not_found(
868868
config_path: Path, rev_range: str, tag: str, util: UtilFixture
@@ -1270,14 +1270,14 @@ def test_changelog_from_current_version_tag_with_nonversion_tag(
12701270

12711271

12721272
@pytest.mark.parametrize(
1273-
"arg,cfg,expected",
1274-
(
1273+
("arg", "cfg", "expected"),
1274+
[
12751275
pytest.param("", "", "default", id="default"),
12761276
pytest.param("", "changelog.cfg", "from config", id="from-config"),
12771277
pytest.param(
12781278
"--template=changelog.cmd", "changelog.cfg", "from cmd", id="from-command"
12791279
),
1280-
),
1280+
],
12811281
)
12821282
def test_changelog_template_option_precedence(
12831283
tmp_commitizen_project: Path,
@@ -1588,12 +1588,12 @@ def test_changelog_template_extra_quotes(
15881588

15891589

15901590
@pytest.mark.parametrize(
1591-
"extra, expected",
1592-
(
1591+
("extra", "expected"),
1592+
[
15931593
pytest.param("key=value=", "value=", id="2-equals"),
15941594
pytest.param("key==value", "=value", id="2-consecutive-equals"),
15951595
pytest.param("key==value==", "=value==", id="multiple-equals"),
1596-
),
1596+
],
15971597
)
15981598
def test_changelog_template_extra_weird_but_valid(
15991599
changelog_tpl: Path,
@@ -1609,7 +1609,7 @@ def test_changelog_template_extra_weird_but_valid(
16091609
assert changelog_file.read_text() == expected
16101610

16111611

1612-
@pytest.mark.parametrize("extra", ("no-equal", "", "=no-key"))
1612+
@pytest.mark.parametrize("extra", ["no-equal", "", "=no-key"])
16131613
def test_changelog_template_extra_bad_format(
16141614
changelog_tpl: Path,
16151615
extra: str,

tests/commands/test_check_command.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ def test_check_conventional_commit_succeeds(
113113

114114
@pytest.mark.parametrize(
115115
"commit_msg",
116-
(
116+
[
117117
"feat!(lang): removed polish language",
118118
"no conventional commit",
119119
(
120120
"ci: check commit message on merge\n"
121121
"testing with more complex commit mes\n\n"
122122
"age with error"
123123
),
124-
),
124+
],
125125
)
126126
def test_check_no_conventional_commit(commit_msg, config, tmpdir):
127127
tempfile = tmpdir.join("temp_commit_file")
@@ -133,12 +133,12 @@ def test_check_no_conventional_commit(commit_msg, config, tmpdir):
133133

134134
@pytest.mark.parametrize(
135135
"commit_msg",
136-
(
136+
[
137137
"feat(lang)!: removed polish language",
138138
"feat(lang): added polish language",
139139
"feat: add polish language",
140140
"bump: 0.0.1 -> 1.0.0",
141-
),
141+
],
142142
)
143143
def test_check_conventional_commit(commit_msg, config, success_mock: MockType, tmpdir):
144144
tempfile = tmpdir.join("temp_commit_file")

tests/commands/test_commit_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ def test_commit_when_customized_expected_raised(config, mocker: MockFixture):
248248

249249
@pytest.mark.usefixtures("staging_is_clean")
250250
def test_commit_when_non_customized_expected_raised(config, mocker: MockFixture):
251-
mocker.patch("questionary.prompt", side_effect=ValueError())
252-
with pytest.raises(ValueError):
251+
mocker.patch("questionary.prompt", side_effect=ValueError("error message"))
252+
with pytest.raises(ValueError, match="error message"):
253253
commands.Commit(config, {})()
254254

255255

tests/commands/test_version_command.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_version_for_showing_project_version(config, capsys):
2929
assert "v0.0.1" in captured.out
3030

3131

32-
@pytest.mark.parametrize("project", (True, False))
32+
@pytest.mark.parametrize("project", [True, False])
3333
def test_version_for_showing_commitizen_version(config, capsys, project: bool):
3434
commands.Version(
3535
config,
@@ -73,7 +73,7 @@ def test_version_for_showing_commitizen_system_info(config, capsys):
7373
assert f"Operating System: {platform.system()}" in captured.out
7474

7575

76-
@pytest.mark.parametrize("project", (True, False))
76+
@pytest.mark.parametrize("project", [True, False])
7777
@pytest.mark.usefixtures("tmp_git_project")
7878
def test_version_use_version_provider(
7979
mocker: MockerFixture,
@@ -104,7 +104,7 @@ def test_version_use_version_provider(
104104

105105

106106
@pytest.mark.parametrize(
107-
"version, expected_version",
107+
("version", "expected_version"),
108108
[
109109
("1.0.0", "1\n"),
110110
("2.1.3", "2\n"),
@@ -126,7 +126,7 @@ def test_version_just_major(config, capsys, version: str, expected_version: str)
126126

127127

128128
@pytest.mark.parametrize(
129-
"version, expected_version",
129+
("version", "expected_version"),
130130
[
131131
("1.0.0", "0\n"),
132132
("2.1.3", "1\n"),
@@ -147,7 +147,7 @@ def test_version_just_minor(config, capsys, version: str, expected_version: str)
147147
assert expected_version == captured.out
148148

149149

150-
@pytest.mark.parametrize("argument", ("major", "minor"))
150+
@pytest.mark.parametrize("argument", ["major", "minor"])
151151
def test_version_just_major_error_no_project(config, capsys, argument: str):
152152
commands.Version(
153153
config,
@@ -164,7 +164,7 @@ def test_version_just_major_error_no_project(config, capsys, argument: str):
164164

165165

166166
@pytest.mark.parametrize(
167-
"version, tag_format, expected_output",
167+
("version", "tag_format", "expected_output"),
168168
[
169169
("1.2.3", "v$version", "v1.2.3\n"),
170170
("1.2.3", "$version", "1.2.3\n"),

0 commit comments

Comments
 (0)