1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Replace open(file, 'r') with open(file)

This commit is contained in:
Andrey Bienkowski 2021-02-10 13:20:11 +03:00
parent bbf8466088
commit f13e10c915
7 changed files with 8 additions and 8 deletions

View file

@ -11,7 +11,7 @@ def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
# intentionally *not* adding an encoding option to open, See:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
with open(os.path.join(here, rel_path), 'r') as fp:
with open(os.path.join(here, rel_path)) as fp:
return fp.read()

View file

@ -145,7 +145,7 @@ def deduce_helpful_msg(req):
msg = " The path does exist. "
# Try to parse and check if it is a requirements file.
try:
with open(req, 'r') as fp:
with open(req) as fp:
# parse first line only
next(parse_requirements(fp.read()))
msg += (

View file

@ -543,7 +543,7 @@ class UninstallPathSet:
elif develop_egg_link:
# develop egg
with open(develop_egg_link, 'r') as fh:
with open(develop_egg_link) as fh:
link_pointer = os.path.normcase(fh.readline().strip())
assert (link_pointer == dist.location), (
'Egg-link {} does not match installed location of {} '

View file

@ -1298,7 +1298,7 @@ def test_install_log(script, data, tmpdir):
'install', data.src.joinpath('chattymodule')]
result = script.pip(*args)
assert 0 == result.stdout.count("HELLO FROM CHATTYMODULE")
with open(f, 'r') as fp:
with open(f) as fp:
# one from egg_info, one from install
assert 2 == fp.read().count("HELLO FROM CHATTYMODULE")
@ -1321,7 +1321,7 @@ def test_cleanup_after_failed_wheel(script, with_wheel):
# One of the effects of not cleaning up is broken scripts:
script_py = script.bin_path / "script.py"
assert script_py.exists(), script_py
shebang = open(script_py, 'r').readline().strip()
shebang = open(script_py).readline().strip()
assert shebang != '#!python', shebang
# OK, assert that we *said* we were cleaning up:
# /!\ if in need to change this, also change test_pep517_no_legacy_cleanup

View file

@ -33,7 +33,7 @@ def test_no_color(script):
pytest.skip("Unable to capture output using script: " + cmd)
try:
with open("/tmp/pip-test-no-color.txt", "r") as output_file:
with open("/tmp/pip-test-no-color.txt") as output_file:
retval = output_file.read()
return retval
finally:

View file

@ -64,7 +64,7 @@ def test_export_rev(script, tmpdir):
url = hide_url('bzr+' + _test_path_to_file_url(source_dir) + '@1')
Bazaar().export(str(export_dir), url=url)
with open(export_dir / 'test_file', 'r') as f:
with open(export_dir / 'test_file') as f:
assert f.read() == 'something initial'

View file

@ -90,7 +90,7 @@ def generate_news(session: Session, version: str) -> None:
def update_version_file(version: str, filepath: str) -> None:
with open(filepath, "r", encoding="utf-8") as f:
with open(filepath, encoding="utf-8") as f:
content = list(f)
file_modified = False