Skip to content

Commit

Permalink
Minor formatting tweaks (#10190)
Browse files Browse the repository at this point in the history
Co-authored-by: Pradyun Gedam <[email protected]>
  • Loading branch information
pradyunsg and pradyunsg authored Jul 23, 2021
1 parent 2de3af1 commit a196b3b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
13 changes: 9 additions & 4 deletions src/pip/_internal/locations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ def _log_context(
root: Optional[str] = None,
prefix: Optional[str] = None,
) -> None:
message = (
"Additional context:" "\nuser = %r" "\nhome = %r" "\nroot = %r" "\nprefix = %r"
)
logger.log(_MISMATCH_LEVEL, message, user, home, root, prefix)
parts = [
"Additional context:",
"user = %r",
"home = %r",
"root = %r",
"prefix = %r",
]

logger.log(_MISMATCH_LEVEL, "\n".join(parts), user, home, root, prefix)


def get_scheme(
Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/resolution/legacy/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _check_dist_requires_python(
version = ".".join(map(str, version_info))
if ignore_requires_python:
logger.debug(
"Ignoring failed Requires-Python check for package %r: " "%s not in %r",
"Ignoring failed Requires-Python check for package %r: %s not in %r",
dist.project_name,
version,
requires_python,
Expand Down Expand Up @@ -344,7 +344,7 @@ def _get_dist_for(self, req: InstallRequirement) -> Distribution:
self._set_req_to_reinstall(req)
else:
logger.info(
"Requirement already satisfied (use --upgrade to upgrade):" " %s",
"Requirement already satisfied (use --upgrade to upgrade): %s",
req,
)
return dist
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,8 +1835,8 @@ def test_invalid_index_url_argument(script, shared_data):
shared_data.find_links3, "Dinner",
expect_error=True)

assert 'WARNING: The index url "--user" seems invalid, ' \
'please provide a scheme.' in result.stderr, str(result)
assert ('WARNING: The index url "--user" seems invalid, '
'please provide a scheme.') in result.stderr, str(result)


def test_valid_index_url_argument(script, shared_data):
Expand Down
10 changes: 5 additions & 5 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,12 @@ def assert_installed(
if without_egg_link:
if egg_link_path in self.files_created:
raise TestFailure(
"unexpected egg link file created: " f"{egg_link_path!r}\n{self}"
f"unexpected egg link file created: {egg_link_path!r}\n{self}"
)
else:
if egg_link_path not in self.files_created:
raise TestFailure(
"expected egg link file missing: " f"{egg_link_path!r}\n{self}"
f"expected egg link file missing: {egg_link_path!r}\n{self}"
)

egg_link_file = self.files_created[egg_link_path]
Expand Down Expand Up @@ -344,7 +344,7 @@ def assert_installed(
normalized_path = os.path.normpath(pkg_dir / f)
if normalized_path not in self.files_created:
raise TestFailure(
f"Package directory {pkg_dir!r} missing " f"expected content {f!r}"
f"Package directory {pkg_dir!r} missing expected content {f!r}"
)

for f in without_files:
Expand Down Expand Up @@ -602,15 +602,15 @@ def run(
# Then default to allowing logged errors.
if allow_stderr_error is not None and not allow_stderr_error:
raise RuntimeError(
"cannot pass allow_stderr_error=False with " "expect_error=True"
"cannot pass allow_stderr_error=False with expect_error=True"
)
allow_stderr_error = True

elif kw.get("expect_stderr"):
# Then default to allowing logged warnings.
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
"cannot pass allow_stderr_warning=False with " "expect_stderr=True"
"cannot pass allow_stderr_warning=False with expect_stderr=True"
)
allow_stderr_warning = True

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_run__allow_stderr_warning_false_error(self, script, arg_name):
"""
kwargs = {"allow_stderr_warning": False, arg_name: True}
expected_start = (
"cannot pass allow_stderr_warning=False with " "allow_stderr_error=True"
"cannot pass allow_stderr_warning=False with allow_stderr_error=True"
)
with assert_error_startswith(RuntimeError, expected_start):
script.run("python", **kwargs)
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_network_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def should_save_password_to_keyring(*a):
# when _prompt_for_password indicates not to save, we should
# never call this function
def should_save_password_to_keyring(*a):
assert False, ("_should_save_password_to_keyring should not be " +
"called")
assert False, "_should_save_password_to_keyring should not be called"
monkeypatch.setattr(auth, '_should_save_password_to_keyring',
should_save_password_to_keyring)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def test_parse_editable_local_extras(
exists_mock.return_value = isdir_mock.return_value = True
abspath_mock.return_value = "/some/path"
assert parse_editable('.[extras]') == (
None, 'file://' + "/some/path", {'extras'},
None, "file:///some/path", {'extras'},
)
abspath_mock.return_value = "/some/path/foo"
assert parse_editable('foo[bar,baz]') == (
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,10 @@ def test_nested_constraints_file(self, monkeypatch, tmpdir):
assert reqs[0].constraint

def test_options_on_a_requirement_line(self, line_processor):
line = 'SomeProject --install-option=yo1 --install-option yo2 '\
'--global-option="yo3" --global-option "yo4"'
line = (
'SomeProject --install-option=yo1 --install-option yo2 '
'--global-option="yo3" --global-option "yo4"'
)
filename = 'filename'
req = line_processor(line, filename, 1)[0]
assert req.global_options == ['yo3', 'yo4']
Expand Down

0 comments on commit a196b3b

Please sign in to comment.