Skip to content

Commit 585037a

Browse files
committed
Cleanup implicit string concatenation
1 parent 9499925 commit 585037a

22 files changed

+63
-57
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ repos:
2828
additional_dependencies: [
2929
'flake8-bugbear==20.1.4',
3030
'flake8-logging-format==0.6.0',
31+
'flake8-implicit-str-concat==0.2.0',
3132
]
3233
exclude: tests/data
3334

src/pip/_internal/index/package_finder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _check_link_requires_python(
8686
return False
8787

8888
logger.debug(
89-
"Ignoring failed Requires-Python check (%s not in: %r) " "for link: %s",
89+
"Ignoring failed Requires-Python check (%s not in: %r) for link: %s",
9090
version,
9191
link.requires_python,
9292
link,
@@ -935,7 +935,7 @@ def _format_versions(cand_iter: Iterable[InstallationCandidate]) -> str:
935935
if best_installed:
936936
# We have an existing version, and its the best version
937937
logger.debug(
938-
"Installed version (%s) is most up-to-date (past versions: " "%s)",
938+
"Installed version (%s) is most up-to-date (past versions: %s)",
939939
installed_version,
940940
_format_versions(best_candidate_result.iter_applicable()),
941941
)

src/pip/_internal/models/search_scope.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def get_formatted_locations(self) -> str:
8888
# exceptions for malformed URLs
8989
if not purl.scheme and not purl.netloc:
9090
logger.warning(
91-
'The index url "%s" seems invalid, ' "please provide a scheme.",
91+
'The index url "%s" seems invalid, please provide a scheme.',
9292
redacted_index_url,
9393
)
9494

src/pip/_internal/operations/freeze.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def freeze(
150150
", ".join(sorted(set(files))),
151151
)
152152

153-
yield ("## The following requirements were added by " "pip freeze:")
153+
yield ("## The following requirements were added by pip freeze:")
154154
for installation in sorted(installations.values(), key=lambda x: x.name.lower()):
155155
if installation.canonical_name not in skip:
156156
yield str(installation).rstrip()

src/pip/_internal/operations/prepare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def _check_download_dir(
254254
hashes.check_against_path(download_path)
255255
except HashMismatch:
256256
logger.warning(
257-
"Previously-downloaded file %s has bad hash. " "Re-downloading.",
257+
"Previously-downloaded file %s has bad hash. Re-downloading.",
258258
download_path,
259259
)
260260
os.unlink(download_path)
@@ -409,7 +409,7 @@ def _fetch_metadata_using_lazy_wheel(self, link: Link) -> Optional[Distribution]
409409
return None
410410
if link.is_file or not link.is_wheel:
411411
logger.debug(
412-
"Lazy wheel is not used as " "%r does not points to a remote wheel",
412+
"Lazy wheel is not used as %r does not points to a remote wheel",
413413
link,
414414
)
415415
return None

src/pip/_internal/wheel_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _should_build(
7474

7575
if not check_binary_allowed(req):
7676
logger.info(
77-
"Skipping wheel build for %s, due to binaries " "being disabled for it.",
77+
"Skipping wheel build for %s, due to binaries being disabled for it.",
7878
req.name,
7979
)
8080
return False
@@ -265,7 +265,7 @@ def _build_one_inside_env(
265265
wheel_hash, length = hash_file(wheel_path)
266266
shutil.move(wheel_path, dest_path)
267267
logger.info(
268-
"Created wheel for %s: " "filename=%s size=%d sha256=%s",
268+
"Created wheel for %s: filename=%s size=%d sha256=%s",
269269
req.name,
270270
wheel_name,
271271
length,

tests/functional/test_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def cache_dir(script):
1010
result = script.run(
1111
"python",
1212
"-c",
13-
"from pip._internal.locations import USER_CACHE_DIR;" "print(USER_CACHE_DIR)",
13+
"from pip._internal.locations import USER_CACHE_DIR;print(USER_CACHE_DIR)",
1414
)
1515
return result.stdout.strip()
1616

tests/functional/test_completion.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ def test_completion_files_after_option(autocomplete, data):
177177
cword="3",
178178
cwd=data.completion_paths,
179179
)
180-
assert "requirements.txt" in res.stdout, (
181-
"autocomplete function could not complete <file> " "after options in command"
182-
)
183-
assert os.path.join("resources", "") in res.stdout, (
184-
"autocomplete function could not complete <dir> " "after options in command"
185-
)
180+
assert (
181+
"requirements.txt" in res.stdout
182+
), "autocomplete function could not complete <file> after options in command"
183+
assert (
184+
os.path.join("resources", "") in res.stdout
185+
), "autocomplete function could not complete <dir> after options in command"
186186
assert not any(
187187
out in res.stdout for out in (os.path.join("REPLAY", ""), "README.txt")
188188
), (
@@ -191,12 +191,12 @@ def test_completion_files_after_option(autocomplete, data):
191191
)
192192
if sys.platform != "win32":
193193
return
194-
assert "readme.txt" in res.stdout, (
195-
"autocomplete function could not complete <file> " "after options in command"
196-
)
197-
assert os.path.join("replay", "") in res.stdout, (
198-
"autocomplete function could not complete <dir> " "after options in command"
199-
)
194+
assert (
195+
"readme.txt" in res.stdout
196+
), "autocomplete function could not complete <file> after options in command"
197+
assert (
198+
os.path.join("replay", "") in res.stdout
199+
), "autocomplete function could not complete <dir> after options in command"
200200

201201

202202
def test_completion_not_files_after_option(autocomplete, data):
@@ -209,12 +209,16 @@ def test_completion_not_files_after_option(autocomplete, data):
209209
cword="2",
210210
cwd=data.completion_paths,
211211
)
212-
assert not any(out in res.stdout for out in ("requirements.txt", "readme.txt",)), (
213-
"autocomplete function completed <file> when " "it should not complete"
214-
)
212+
assert not any(
213+
out in res.stdout
214+
for out in (
215+
"requirements.txt",
216+
"readme.txt",
217+
)
218+
), "autocomplete function completed <file> when it should not complete"
215219
assert not any(
216220
os.path.join(out, "") in res.stdout for out in ("replay", "resources")
217-
), ("autocomplete function completed <dir> when " "it should not complete")
221+
), "autocomplete function completed <dir> when it should not complete"
218222

219223

220224
@pytest.mark.parametrize("cl_opts", ["-U", "--user", "-h"])
@@ -228,12 +232,16 @@ def test_completion_not_files_after_nonexpecting_option(autocomplete, data, cl_o
228232
cword="2",
229233
cwd=data.completion_paths,
230234
)
231-
assert not any(out in res.stdout for out in ("requirements.txt", "readme.txt",)), (
232-
"autocomplete function completed <file> when " "it should not complete"
233-
)
235+
assert not any(
236+
out in res.stdout
237+
for out in (
238+
"requirements.txt",
239+
"readme.txt",
240+
)
241+
), "autocomplete function completed <file> when it should not complete"
234242
assert not any(
235243
os.path.join(out, "") in res.stdout for out in ("replay", "resources")
236-
), ("autocomplete function completed <dir> when " "it should not complete")
244+
), "autocomplete function completed <dir> when it should not complete"
237245

238246

239247
def test_completion_directories_after_option(autocomplete, data):
@@ -252,7 +260,7 @@ def test_completion_directories_after_option(autocomplete, data):
252260
assert not any(
253261
out in res.stdout
254262
for out in ("requirements.txt", "README.txt", os.path.join("REPLAY", ""))
255-
), ("autocomplete function completed <dir> when " "it should not complete")
263+
), "autocomplete function completed <dir> when it should not complete"
256264
if sys.platform == "win32":
257265
assert (
258266
os.path.join("replay", "") in res.stdout

tests/functional/test_freeze.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ def test_freeze_with_requirement_option_package_repeated_multi_file(script):
834834
"Requirement file [hint2.txt] contains NoExist, but package "
835835
"'NoExist' is not installed\n"
836836
)
837-
err2 = "Requirement simple included multiple times " "[hint1.txt, hint2.txt]\n"
837+
err2 = "Requirement simple included multiple times [hint1.txt, hint2.txt]\n"
838838
assert err1 in result.stderr
839839
assert err2 in result.stderr
840840
# there shouldn't be any other 'is not installed' warnings

tests/functional/test_install.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,9 +1615,7 @@ def test_double_install_fail(script, resolver_variant):
16151615
expect_error=(resolver_variant == "legacy"),
16161616
)
16171617
if resolver_variant == "legacy":
1618-
msg = (
1619-
"Double requirement given: pip==7.1.2 (already in pip==7.*, " "name='pip')"
1620-
)
1618+
msg = "Double requirement given: pip==7.1.2 (already in pip==7.*, name='pip')"
16211619
assert msg in result.stderr
16221620

16231621

@@ -1939,7 +1937,7 @@ def test_invalid_index_url_argument(script, shared_data):
19391937
)
19401938

19411939
assert (
1942-
'WARNING: The index url "--user" seems invalid, ' "please provide a scheme."
1940+
'WARNING: The index url "--user" seems invalid, please provide a scheme.'
19431941
) in result.stderr, str(result)
19441942

19451943

tests/functional/test_install_reqs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ def test_install_distribution_union_with_versions(
654654
assert ("localextras[baz] 0.0.2 depends on localextras 0.0.2") in result.stdout
655655
else:
656656
assert (
657-
"Successfully installed LocalExtras-0.0.1 simple-3.0 " "singlemodule-0.0.1"
657+
"Successfully installed LocalExtras-0.0.1 simple-3.0 singlemodule-0.0.1"
658658
) in result.stdout
659659

660660

@@ -705,8 +705,7 @@ def test_install_unsupported_wheel_file(script, data):
705705
expect_stderr=True,
706706
)
707707
assert (
708-
"simple.dist-0.1-py1-none-invalid.whl is not a supported "
709-
+ "wheel on this platform"
708+
"simple.dist-0.1-py1-none-invalid.whl is not a supported wheel on this platform"
710709
in result.stderr
711710
)
712711
assert len(result.files_created) == 0

tests/functional/test_list.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def test_outdated_flag(script, data):
234234
script.pip(
235235
"install",
236236
"-e",
237-
"git+https://github.com/pypa/pip-test-package.git" "@0.1#egg=pip-test-package",
237+
"git+https://github.com/pypa/[email protected]#egg=pip-test-package",
238238
)
239239
result = script.pip(
240240
"list",
@@ -283,7 +283,7 @@ def test_outdated_columns_flag(script, data):
283283
script.pip(
284284
"install",
285285
"-e",
286-
"git+https://github.com/pypa/pip-test-package.git" "@0.1#egg=pip-test-package",
286+
"git+https://github.com/pypa/[email protected]#egg=pip-test-package",
287287
)
288288
result = script.pip(
289289
"list",
@@ -397,7 +397,7 @@ def test_outdated_editables_flag(script, data):
397397
result = script.pip(
398398
"install",
399399
"-e",
400-
"git+https://github.com/pypa/pip-test-package.git" "@0.1#egg=pip-test-package",
400+
"git+https://github.com/pypa/[email protected]#egg=pip-test-package",
401401
)
402402
result = script.pip(
403403
"list",
@@ -420,7 +420,7 @@ def test_outdated_editables_columns_flag(script, data):
420420
result = script.pip(
421421
"install",
422422
"-e",
423-
"git+https://github.com/pypa/pip-test-package.git" "@0.1#egg=pip-test-package",
423+
"git+https://github.com/pypa/[email protected]#egg=pip-test-package",
424424
)
425425
result = script.pip(
426426
"list",

tests/functional/test_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ def test_timeout(script):
1515
"Could not fetch URL https://pypi.org/simple/INITools/: "
1616
"timed out" in result.stdout
1717
)
18-
assert "Could not fetch URL https://pypi.org/simple/: " "timed out" in result.stdout
18+
assert "Could not fetch URL https://pypi.org/simple/: timed out" in result.stdout

tests/functional/test_uninstall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def test_uninstall_without_record_fails(script, data, installer):
537537

538538
result2 = script.pip("uninstall", "simple.dist", "-y", expect_error=True)
539539
expected_error_message = (
540-
"ERROR: Cannot uninstall simple.dist 0.1, " "RECORD file not found."
540+
"ERROR: Cannot uninstall simple.dist 0.1, RECORD file not found."
541541
)
542542
if not isinstance(installer, str) or not installer.strip() or installer == "pip":
543543
expected_error_message += (
@@ -546,7 +546,7 @@ def test_uninstall_without_record_fails(script, data, installer):
546546
"simple.dist==0.1'."
547547
)
548548
elif installer:
549-
expected_error_message += " Hint: The package was installed by " "{}.".format(
549+
expected_error_message += " Hint: The package was installed by {}.".format(
550550
installer
551551
)
552552
assert result2.stderr.rstrip() == expected_error_message

tests/unit/test_collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def test_get_html_response_dont_log_clear_text_password(mock_raise_for_status, c
231231
[
232232
(b"<html></html>", "https://example.com/", "https://example.com/"),
233233
(
234-
b"<html><head>" b'<base href="https://foo.example.com/">' b"</head></html>",
234+
b'<html><head><base href="https://foo.example.com/"></head></html>',
235235
"https://example.com/",
236236
"https://foo.example.com/",
237237
),

tests/unit/test_command_install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_rejection_for_location_requirement_options():
8989
OSError("Illegal byte sequence"),
9090
True,
9191
True,
92-
"Could not install" " packages due to an OSError.\n",
92+
"Could not install packages due to an OSError.\n",
9393
),
9494
(
9595
OSError(errno.EACCES, "No file permission"),
@@ -104,7 +104,7 @@ def test_rejection_for_location_requirement_options():
104104
OSError("Illegal byte sequence"),
105105
True,
106106
False,
107-
"Could not" " install packages due to an OSError.\n",
107+
"Could not install packages due to an OSError.\n",
108108
),
109109
(
110110
OSError(errno.EACCES, "No file permission"),

tests/unit/test_direct_url_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_from_link_archive():
135135
assert direct_url.url == "https://g.c/archive.tgz"
136136
assert isinstance(direct_url.info, ArchiveInfo)
137137
direct_url = direct_url_from_link(
138-
Link("https://g.c/archive.tgz" "#sha1=1b8c5bc61a86f377fea47b4276c8c8a5842d2220")
138+
Link("https://g.c/archive.tgz#sha1=1b8c5bc61a86f377fea47b4276c8c8a5842d2220")
139139
)
140140
assert isinstance(direct_url.info, ArchiveInfo)
141141
assert direct_url.info.hash == "sha1=1b8c5bc61a86f377fea47b4276c8c8a5842d2220"

tests/unit/test_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_check_link_requires_python__invalid_requires(caplog):
103103
assert actual
104104

105105
expected_message = (
106-
"Ignoring invalid Requires-Python ('invalid') for link: " "https://example.com"
106+
"Ignoring invalid Requires-Python ('invalid') for link: https://example.com"
107107
)
108108
check_caplog(caplog, "DEBUG", expected_message)
109109

tests/unit/test_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_format(self, level_name, expected, utc):
5353
@pytest.mark.parametrize(
5454
"level_name, expected",
5555
[
56-
("INFO", "2019-01-17T06:00:37,040 hello\n" "2019-01-17T06:00:37,040 world"),
56+
("INFO", "2019-01-17T06:00:37,040 hello\n2019-01-17T06:00:37,040 world"),
5757
(
5858
"WARNING",
5959
"2019-01-17T06:00:37,040 WARNING: hello\n"

tests/unit/test_req_file.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ def test_hash_options(self, line_processor):
345345
req = line_processor(line, filename, 1)[0]
346346
assert req.hash_options == {
347347
"sha256": [
348-
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e730433" "62938b9824",
349-
"486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65" "260e9cb8a7",
348+
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
349+
"486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7",
350350
],
351351
"sha384": [
352352
"59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcd"
@@ -596,7 +596,7 @@ def test_multiple_appending_options(self, tmpdir, finder, options):
596596
assert finder.index_urls == ["url1", "url2"]
597597

598598
def test_expand_existing_env_variables(self, tmpdir, finder):
599-
template = "https://{}:[email protected]/" "user/{}/archive/master.zip"
599+
template = "https://{}:[email protected]/user/{}/archive/master.zip"
600600

601601
def make_var(name):
602602
return f"${{{name}}}"

tests/unit/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,11 @@ def test_rmtree_retries_for_3sec(tmpdir, monkeypatch):
423423

424424
if sys.byteorder == "little":
425425
expected_byte_string = (
426-
"b'\\xff\\xfe/\\x00p\\x00a\\x00t\\x00h\\x00/" "\\x00d\\x00\\xe9\\x00f\\x00'"
426+
"b'\\xff\\xfe/\\x00p\\x00a\\x00t\\x00h\\x00/\\x00d\\x00\\xe9\\x00f\\x00'"
427427
)
428428
elif sys.byteorder == "big":
429429
expected_byte_string = (
430-
"b'\\xfe\\xff\\x00/\\x00p\\x00a\\x00t\\x00h\\" "x00/\\x00d\\x00\\xe9\\x00f'"
430+
"b'\\xfe\\xff\\x00/\\x00p\\x00a\\x00t\\x00h\\x00/\\x00d\\x00\\xe9\\x00f'"
431431
)
432432

433433

tests/unit/test_utils_subprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_call_subprocess_stdout_only(capfd, monkeypatch, stdout_only, expected):
152152
[
153153
sys.executable,
154154
"-c",
155-
"import sys; " "sys.stdout.write('out\\n'); " "sys.stderr.write('err\\n')",
155+
"import sys; sys.stdout.write('out\\n'); sys.stderr.write('err\\n')",
156156
],
157157
stdout_only=stdout_only,
158158
)

0 commit comments

Comments
 (0)