Skip to content

Commit b3ac4bf

Browse files
committed
fix: direct .format() usage in exception messages
src/libvcs/sync/git.py:175:13: EM103 Exception must not use a `.format()` string directly, assign to variable first tests/test_exc.py:14:32: EM101 Exception must not use a string literal, assign to variable first tests/test_exc.py:31:32: EM101 Exception must not use a string literal, assign to variable first tests/test_exc.py:42:32: EM101 Exception must not use a string literal, assign to variable first Found 4 errors.
1 parent 3a236ef commit b3ac4bf

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/libvcs/sync/git.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,15 @@ def convert_pip_url(pip_url: str) -> VCSLocation:
171171
url, rev = base_convert_pip_url(pip_url)
172172
url = url.replace("ssh://", "")
173173
elif "github.com:" in pip_url:
174-
raise exc.LibVCSException(
174+
msg = (
175175
"Repo {} is malformatted, please use the convention {} for "
176176
"ssh / private GitHub repositories.".format(
177177
pip_url,
178178
"git+https://github.com/username/repo.git",
179-
),
179+
)
180+
)
181+
raise exc.LibVCSException(
182+
msg,
180183
)
181184
else:
182185
url, rev = base_convert_pip_url(pip_url)

tests/test_exc.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def test_command_error() -> None:
1111
with pytest.raises(exc.CommandError) as e:
1212
returncode = 0
1313
command = ["command", "arg"]
14-
raise exc.CommandError("this is output", returncode, command)
14+
msg = "this is output"
15+
raise exc.CommandError(msg, returncode, command)
1516

1617
assert command is not None
1718

@@ -28,7 +29,8 @@ def test_command_error() -> None:
2829
with pytest.raises(exc.CommandError) as e:
2930
returncode = 0
3031
command = ["command", "arg"]
31-
raise exc.CommandError("", returncode, command)
32+
msg = ""
33+
raise exc.CommandError(msg, returncode, command)
3234
assert e.value.cmd == " ".join(command)
3335
assert str(e.value) == exc.CommandError.message.format(
3436
returncode=e.value.returncode,
@@ -39,7 +41,8 @@ def test_command_error() -> None:
3941

4042
with pytest.raises(exc.CommandError) as e:
4143
command_2 = "command arg"
42-
raise exc.CommandError("this is output", 0, command_2)
44+
msg = "this is output"
45+
raise exc.CommandError(msg, 0, command_2)
4346

4447
assert command_2 is not None
4548
assert e.value.cmd == command_2

0 commit comments

Comments
 (0)