diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py index 35ce0288d19..19818fbb9e7 100644 --- a/src/pip/_internal/cli/cmdoptions.py +++ b/src/pip/_internal/cli/cmdoptions.py @@ -98,7 +98,7 @@ def check_dist_restriction(options, check_target=False): :param check_target: Whether or not to check if --target is being used. """ dist_restriction_set = any( - [options.python_version, options.platform, options.abi, options.implementation,] + [options.python_version, options.platform, options.abi, options.implementation] ) binary_only = FormatControl(set(), {":all:"}) @@ -996,5 +996,5 @@ def check_list_path_option(options): index_group = { "name": "Package Index Options", - "options": [index_url, extra_index_url, no_index, find_links,], + "options": [index_url, extra_index_url, no_index, find_links], } # type: Dict[str, Any] diff --git a/src/pip/_internal/cli/progress_bars.py b/src/pip/_internal/cli/progress_bars.py index 2201b7dbc62..8c051e3a94d 100644 --- a/src/pip/_internal/cli/progress_bars.py +++ b/src/pip/_internal/cli/progress_bars.py @@ -243,7 +243,7 @@ def update(self): phase = self.next_phase() suffix = self.suffix % self line = "".join( - [message, " " if message else "", phase, " " if suffix else "", suffix,] + [message, " " if message else "", phase, " " if suffix else "", suffix] ) self.writeln(line) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 54ffac7ca83..c935580fd79 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -723,9 +723,7 @@ def create_env_error_message(error, show_traceback, using_user_site): permissions_part = "Check the permissions" if not using_user_site: - parts.extend( - [user_option_part, " or ", permissions_part.lower(),] - ) + parts.extend([user_option_part, " or ", permissions_part.lower()]) else: parts.append(permissions_part) parts.append(".\n") diff --git a/src/pip/_internal/network/session.py b/src/pip/_internal/network/session.py index 68aa72613c2..fd44bc2131b 100644 --- a/src/pip/_internal/network/session.py +++ b/src/pip/_internal/network/session.py @@ -102,7 +102,7 @@ def user_agent(): data = { "installer": {"name": "pip", "version": __version__}, "python": platform.python_version(), - "implementation": {"name": platform.python_implementation(),}, + "implementation": {"name": platform.python_implementation()}, } if data["implementation"]["name"] == "CPython": diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 366243f1eb7..ea5a5369771 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -54,7 +54,7 @@ if PY2: CopytreeKwargs = TypedDict( "CopytreeKwargs", - {"ignore": Callable[[str, List[str]], List[str]], "symlinks": bool,}, + {"ignore": Callable[[str, List[str]], List[str]], "symlinks": bool}, total=False, ) else: diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index 4310b3f6b13..1430cd5bbe6 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -383,7 +383,7 @@ def _set_requirement(self): op = "===" self.req = Requirement( - "".join([self.metadata["Name"], op, self.metadata["Version"],]) + "".join([self.metadata["Name"], op, self.metadata["Version"]]) ) def warn_on_mismatching_name(self): diff --git a/src/pip/_internal/utils/logging.py b/src/pip/_internal/utils/logging.py index 0abf5d2d5aa..69c3051563f 100644 --- a/src/pip/_internal/utils/logging.py +++ b/src/pip/_internal/utils/logging.py @@ -343,7 +343,7 @@ def setup_logging(verbosity, no_color, user_log_file): }, }, "formatters": { - "indent": {"()": IndentingFormatter, "format": "%(message)s",}, + "indent": {"()": IndentingFormatter, "format": "%(message)s"}, "indent_with_timestamp": { "()": IndentingFormatter, "format": "%(message)s", @@ -385,7 +385,7 @@ def setup_logging(verbosity, no_color, user_log_file): "formatter": "indent_with_timestamp", }, }, - "root": {"level": root_level, "handlers": handlers,}, + "root": {"level": root_level, "handlers": handlers}, "loggers": {"pip._vendor": {"level": vendored_log_level}}, } ) diff --git a/tests/conftest.py b/tests/conftest.py index 5cd1094aa3f..a1e5d0fef86 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -178,7 +178,7 @@ def isolate(tmpdir): # Note: this will only take effect in subprocesses... home_drive, home_path = os.path.splitdrive(home_dir) os.environ.update( - {"USERPROFILE": home_dir, "HOMEDRIVE": home_drive, "HOMEPATH": home_path,} + {"USERPROFILE": home_dir, "HOMEDRIVE": home_drive, "HOMEPATH": home_path} ) for env_var, sub_path in ( ("APPDATA", "AppData/Roaming"), diff --git a/tests/data/packages/LocalEnvironMarker/setup.py b/tests/data/packages/LocalEnvironMarker/setup.py index 72e591b2094..4d991a6afa0 100644 --- a/tests/data/packages/LocalEnvironMarker/setup.py +++ b/tests/data/packages/LocalEnvironMarker/setup.py @@ -21,5 +21,5 @@ def path_to_url(path): name="LocalEnvironMarker", version="0.0.1", packages=find_packages(), - extras_require={":python_version == '2.7'": ["simple"],}, + extras_require={":python_version == '2.7'": ["simple"]}, ) diff --git a/tests/functional/test_debug.py b/tests/functional/test_debug.py index aed63b9ddde..7746944712f 100644 --- a/tests/functional/test_debug.py +++ b/tests/functional/test_debug.py @@ -45,7 +45,7 @@ def test_debug__library_versions(script): assert "{}=={}".format(name, value) in result.stdout -@pytest.mark.parametrize("args", [[], ["--verbose"],]) +@pytest.mark.parametrize("args", [[], ["--verbose"]]) def test_debug__tags(script, args): """ Check the compatible tag output. @@ -65,7 +65,7 @@ def test_debug__tags(script, args): @pytest.mark.parametrize( - "args, expected", [(["--python-version", "3.7"], "(target: version_info='3.7')"),] + "args, expected", [(["--python-version", "3.7"], "(target: version_info='3.7')")] ) def test_debug__target_options(script, args, expected): """ diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 1d9a0eaeb4d..6c583fbaab6 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -1896,7 +1896,7 @@ def test_install_yanked_file_and_print_warning(script, data): assert "Successfully installed simple-3.0\n" in result.stdout, str(result) -@pytest.mark.parametrize("install_args", [(), ("--trusted-host", "localhost"),]) +@pytest.mark.parametrize("install_args", [(), ("--trusted-host", "localhost")]) def test_install_sends_client_cert(install_args, script, cert_factory, data): cert_path = cert_factory() ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) @@ -1906,7 +1906,7 @@ def test_install_sends_client_cert(install_args, script, cert_factory, data): server = make_mock_server(ssl_context=ctx) server.mock.side_effect = [ - package_page({"simple-3.0.tar.gz": "/files/simple-3.0.tar.gz",}), + package_page({"simple-3.0.tar.gz": "/files/simple-3.0.tar.gz"}), file_response(str(data.packages / "simple-3.0.tar.gz")), ] diff --git a/tests/functional/test_install_config.py b/tests/functional/test_install_config.py index 89bd43dc2e1..11ff649eca6 100644 --- a/tests/functional/test_install_config.py +++ b/tests/functional/test_install_config.py @@ -249,7 +249,7 @@ def test_prompt_for_authentication(script, data, cert_factory): server = make_mock_server(ssl_context=ctx) server.mock.side_effect = [ - package_page({"simple-3.0.tar.gz": "/files/simple-3.0.tar.gz",}), + package_page({"simple-3.0.tar.gz": "/files/simple-3.0.tar.gz"}), authorization_response(str(data.packages / "simple-3.0.tar.gz")), ] @@ -286,7 +286,7 @@ def test_do_not_prompt_for_authentication(script, data, cert_factory): server = make_mock_server(ssl_context=ctx) server.mock.side_effect = [ - package_page({"simple-3.0.tar.gz": "/files/simple-3.0.tar.gz",}), + package_page({"simple-3.0.tar.gz": "/files/simple-3.0.tar.gz"}), authorization_response(str(data.packages / "simple-3.0.tar.gz")), ] diff --git a/tests/functional/test_install_wheel.py b/tests/functional/test_install_wheel.py index ec0e28d2fe9..cf65dabc6af 100644 --- a/tests/functional/test_install_wheel.py +++ b/tests/functional/test_install_wheel.py @@ -115,7 +115,7 @@ def test_basic_install_from_unicode_wheel(script, data): make_wheel( "unicode_package", "1.0", - extra_files={"வணக்கம்/__init__.py": b"", "வணக்கம்/નમસ્તે.py": b"",}, + extra_files={"வணக்கம்/__init__.py": b"", "வணக்கம்/નમસ્તે.py": b""}, ).save_to_dir(script.scratch_path) result = script.pip( @@ -287,7 +287,7 @@ def test_wheel_record_lines_in_deterministic_order(script, data): def test_wheel_record_lines_have_hash_for_data_files(script): package = make_wheel( - "simple", "0.1.0", extra_data_files={"purelib/info.txt": "c",}, + "simple", "0.1.0", extra_data_files={"purelib/info.txt": "c"}, ).save_to_dir(script.scratch_path) script.pip("install", package) record_file = script.site_packages_path / "simple-0.1.0.dist-info" / "RECORD" diff --git a/tests/functional/test_new_resolver.py b/tests/functional/test_new_resolver.py index baefc1b4709..c5a8a176a48 100644 --- a/tests/functional/test_new_resolver.py +++ b/tests/functional/test_new_resolver.py @@ -196,7 +196,7 @@ def test_new_resolver_ignore_dependencies(script): @pytest.mark.parametrize( - "root_dep", ["base[add]", "base[add] >= 0.1.0",], + "root_dep", ["base[add]", "base[add] >= 0.1.0"], ) def test_new_resolver_installs_extras(tmpdir, script, root_dep): req_file = tmpdir.joinpath("requirements.txt") @@ -901,7 +901,7 @@ def _wheel_from_index(script, name, version, requires, extras): return name @pytest.mark.parametrize( - "pkg_builder", [_local_with_setup, _direct_wheel, _wheel_from_index,], + "pkg_builder", [_local_with_setup, _direct_wheel, _wheel_from_index], ) def test_new_resolver_extra_merge_in_package( self, monkeypatch, script, pkg_builder, diff --git a/tests/functional/test_search.py b/tests/functional/test_search.py index 8d24ecf59f9..276d522ec55 100644 --- a/tests/functional/test_search.py +++ b/tests/functional/test_search.py @@ -29,8 +29,8 @@ def test_pypi_xml_transformation(): """ pypi_hits = [ - {"name": "foo", "summary": "foo summary", "version": "1.0",}, - {"name": "foo", "summary": "foo summary v2", "version": "2.0",}, + {"name": "foo", "summary": "foo summary", "version": "1.0"}, + {"name": "foo", "summary": "foo summary v2", "version": "2.0"}, { "_pypi_ordering": 50, "name": "bar", @@ -39,8 +39,8 @@ def test_pypi_xml_transformation(): }, ] expected = [ - {"versions": ["1.0", "2.0"], "name": "foo", "summary": "foo summary v2",}, - {"versions": ["1.0"], "name": "bar", "summary": "bar summary",}, + {"versions": ["1.0", "2.0"], "name": "foo", "summary": "foo summary v2"}, + {"versions": ["1.0"], "name": "bar", "summary": "bar summary"}, ] assert transform_hits(pypi_hits) == expected diff --git a/tests/functional/test_uninstall.py b/tests/functional/test_uninstall.py index 830127cbe9e..91498a340d4 100644 --- a/tests/functional/test_uninstall.py +++ b/tests/functional/test_uninstall.py @@ -93,7 +93,7 @@ def test_uninstall_easy_install_after_import(script): assert_all_changes( result, result2, - [script.venv / "build", "cache", script.site_packages / "easy-install.pth",], + [script.venv / "build", "cache", script.site_packages / "easy-install.pth"], ) @@ -198,7 +198,7 @@ def test_uninstall_entry_point_colon_in_name(script, console_scripts): name=pkg_name, version="0.1", entry_points={ - "console_scripts": [console_scripts,], + "console_scripts": [console_scripts], "pip_test.ep": [ "ep:name1 = distutils_install", "ep:name2 = distutils_install", @@ -227,7 +227,7 @@ def test_uninstall_gui_scripts(script): script, name=pkg_name, version="0.1", - entry_points={"gui_scripts": ["test_ = distutils_install",],}, + entry_points={"gui_scripts": ["test_ = distutils_install"]}, ) script_name = script.bin_path.joinpath("test_") if sys.platform == "win32": @@ -263,7 +263,7 @@ def test_uninstall_console_scripts_uppercase_name(script): script, name="ep_install", version="0.1", - entry_points={"console_scripts": ["Test = distutils_install",],}, + entry_points={"console_scripts": ["Test = distutils_install"]}, ) script_name = script.bin_path.joinpath("Test" + script.exe) @@ -287,7 +287,7 @@ def test_uninstall_easy_installed_console_scripts(script): assert_all_changes( result, result2, - [script.venv / "build", "cache", script.site_packages / "easy-install.pth",], + [script.venv / "build", "cache", script.site_packages / "easy-install.pth"], ) diff --git a/tests/functional/test_uninstall_user.py b/tests/functional/test_uninstall_user.py index 77570c3b4f4..90642b9169b 100644 --- a/tests/functional/test_uninstall_user.py +++ b/tests/functional/test_uninstall_user.py @@ -69,5 +69,5 @@ def test_uninstall_editable_from_usersite(self, script, data): assert_all_changes( result1, result2, - [script.venv / "build", "cache", script.user_site / "easy-install.pth",], + [script.venv / "build", "cache", script.user_site / "easy-install.pth"], ) diff --git a/tests/lib/certs.py b/tests/lib/certs.py index 40bace8b1de..58ab300d1aa 100644 --- a/tests/lib/certs.py +++ b/tests/lib/certs.py @@ -17,7 +17,7 @@ def make_tls_cert(hostname): key = rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_backend() ) - subject = issuer = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, hostname),]) + subject = issuer = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, hostname)]) cert = ( x509.CertificateBuilder() .subject_name(subject) diff --git a/tests/lib/server.py b/tests/lib/server.py index a9c56531ece..600a5dc6912 100644 --- a/tests/lib/server.py +++ b/tests/lib/server.py @@ -167,7 +167,7 @@ def text_html_response(text): # type: (Text) -> Responder def responder(environ, start_response): # type: (Environ, StartResponse) -> Body - start_response("200 OK", [("Content-Type", "text/html; charset=UTF-8"),]) + start_response("200 OK", [("Content-Type", "text/html; charset=UTF-8")]) return [text.encode("utf-8")] return responder @@ -233,7 +233,7 @@ def responder(environ, start_response): # type: (Environ, StartResponse) -> Body start_response( - "401 Unauthorized", [("WWW-Authenticate", "Basic"),], + "401 Unauthorized", [("WWW-Authenticate", "Basic")], ) with open(path, "rb") as f: diff --git a/tests/lib/wheel.py b/tests/lib/wheel.py index 8f1401cdfe5..06e2133bbad 100644 --- a/tests/lib/wheel.py +++ b/tests/lib/wheel.py @@ -98,7 +98,7 @@ def make_metadata_file( return File(path, ensure_binary(value)) metadata = CaseInsensitiveDict( - {"Metadata-Version": "2.1", "Name": name, "Version": version,} + {"Metadata-Version": "2.1", "Name": name, "Version": version} ) if updates is not _default: metadata.update(updates) @@ -244,7 +244,7 @@ def record_file_maker_wrapper( def wheel_name(name, version, pythons, abis, platforms): # type: (str, str, str, str, str) -> str stem = "-".join( - [name, version, ".".join(pythons), ".".join(abis), ".".join(platforms),] + [name, version, ".".join(pythons), ".".join(abis), ".".join(platforms)] ) return "{}.whl".format(stem) diff --git a/tests/unit/test_collector.py b/tests/unit/test_collector.py index f2b0e296797..98caced0afe 100644 --- a/tests/unit/test_collector.py +++ b/tests/unit/test_collector.py @@ -34,7 +34,7 @@ @pytest.mark.parametrize( - "url", ["ftp://python.org/python-3.7.1.zip", "file:///opt/data/pip-18.0.tar.gz",], + "url", ["ftp://python.org/python-3.7.1.zip", "file:///opt/data/pip-18.0.tar.gz"], ) def test_get_html_response_archive_to_naive_scheme(url): """ @@ -62,22 +62,20 @@ def test_get_html_response_archive_to_http_scheme( """ session = mock.Mock(PipSession) session.head.return_value = mock.Mock( - **{"request.method": "HEAD", "headers": {"Content-Type": content_type},} + **{"request.method": "HEAD", "headers": {"Content-Type": content_type}} ) with pytest.raises(_NotHTML) as ctx: _get_html_response(url, session=session) - session.assert_has_calls( - [mock.call.head(url, allow_redirects=True),] - ) + session.assert_has_calls([mock.call.head(url, allow_redirects=True)]) mock_raise_for_status.assert_called_once_with(session.head.return_value) assert ctx.value.args == (content_type, "HEAD") @pytest.mark.parametrize( "url", - [("ftp://python.org/python-3.7.1.zip"), ("file:///opt/data/pip-18.0.tar.gz"),], + [("ftp://python.org/python-3.7.1.zip"), ("file:///opt/data/pip-18.0.tar.gz")], ) def test_get_html_page_invalid_content_type_archive(caplog, url): """`_get_html_page()` should warn if an archive URL is not HTML @@ -98,7 +96,7 @@ def test_get_html_page_invalid_content_type_archive(caplog, url): @pytest.mark.parametrize( - "url", ["http://python.org/python-3.7.1.zip", "https://pypi.org/pip-18.0.tar.gz",], + "url", ["http://python.org/python-3.7.1.zip", "https://pypi.org/pip-18.0.tar.gz"], ) @mock.patch("pip._internal.index.collector.raise_for_status") def test_get_html_response_archive_to_http_scheme_is_html(mock_raise_for_status, url): @@ -108,7 +106,7 @@ def test_get_html_response_archive_to_http_scheme_is_html(mock_raise_for_status, """ session = mock.Mock(PipSession) session.head.return_value = mock.Mock( - **{"request.method": "HEAD", "headers": {"Content-Type": "text/html"},} + **{"request.method": "HEAD", "headers": {"Content-Type": "text/html"}} ) session.get.return_value = mock.Mock(headers={"Content-Type": "text/html"}) @@ -118,7 +116,7 @@ def test_get_html_response_archive_to_http_scheme_is_html(mock_raise_for_status, assert session.mock_calls == [ mock.call.head(url, allow_redirects=True), mock.call.get( - url, headers={"Accept": "text/html", "Cache-Control": "max-age=0",} + url, headers={"Accept": "text/html", "Cache-Control": "max-age=0"} ), ] assert mock_raise_for_status.mock_calls == [ @@ -145,7 +143,7 @@ def test_get_html_response_no_head(mock_raise_for_status, url): # Mock the headers dict to ensure it is accessed. session.get.return_value = mock.Mock( - headers=mock.Mock(**{"get.return_value": "text/html",}) + headers=mock.Mock(**{"get.return_value": "text/html"}) ) resp = _get_html_response(url, session=session) @@ -153,7 +151,7 @@ def test_get_html_response_no_head(mock_raise_for_status, url): assert resp is not None assert session.head.call_count == 0 assert session.get.mock_calls == [ - mock.call(url, headers={"Accept": "text/html", "Cache-Control": "max-age=0",}), + mock.call(url, headers={"Accept": "text/html", "Cache-Control": "max-age=0"}), mock.call().headers.get("Content-Type", ""), ] mock_raise_for_status.assert_called_once_with(resp) @@ -169,7 +167,7 @@ def test_get_html_response_dont_log_clear_text_password(mock_raise_for_status, c # Mock the headers dict to ensure it is accessed. session.get.return_value = mock.Mock( - headers=mock.Mock(**{"get.return_value": "text/html",}) + headers=mock.Mock(**{"get.return_value": "text/html"}) ) caplog.set_level(logging.DEBUG) @@ -509,7 +507,7 @@ def test_get_html_page_invalid_scheme(caplog, url, vcs_scheme): @pytest.mark.parametrize( - "content_type", ["application/xhtml+xml", "application/json",], + "content_type", ["application/xhtml+xml", "application/json"], ) @mock.patch("pip._internal.index.collector.raise_for_status") def test_get_html_page_invalid_content_type( @@ -524,7 +522,7 @@ def test_get_html_page_invalid_content_type( session = mock.Mock(PipSession) session.get.return_value = mock.Mock( - **{"request.method": "GET", "headers": {"Content-Type": content_type},} + **{"request.method": "GET", "headers": {"Content-Type": content_type}} ) assert _get_html_page(link, session=session) is None mock_raise_for_status.assert_called_once_with(session.get.return_value) diff --git a/tests/unit/test_index.py b/tests/unit/test_index.py index f6a4bbd8068..4474b7e760f 100644 --- a/tests/unit/test_index.py +++ b/tests/unit/test_index.py @@ -295,7 +295,7 @@ def test_filter_unallowed_hashes__log_message_with_no_match(caplog): class TestCandidateEvaluator: @pytest.mark.parametrize( "allow_all_prereleases, prefer_binary", - [(False, False), (False, True), (True, False), (True, True),], + [(False, False), (False, True), (True, False), (True, True)], ) def test_create(self, allow_all_prereleases, prefer_binary): target_python = TargetPython() @@ -486,7 +486,7 @@ def test_sort_best_candidate__best_yanked_but_not_all( class TestPackageFinder: @pytest.mark.parametrize( "allow_all_prereleases, prefer_binary", - [(False, False), (False, True), (True, False), (True, True),], + [(False, False), (False, True), (True, False), (True, True)], ) def test_create__candidate_prefs( self, allow_all_prereleases, prefer_binary, @@ -658,7 +658,7 @@ def test_make_link_evaluator( @pytest.mark.parametrize( "allow_all_prereleases, prefer_binary", - [(False, False), (False, True), (True, False), (True, True),], + [(False, False), (False, True), (True, False), (True, True)], ) def test_make_candidate_evaluator( self, allow_all_prereleases, prefer_binary, diff --git a/tests/unit/test_link.py b/tests/unit/test_link.py index b80c6622cf7..e439a0f1735 100644 --- a/tests/unit/test_link.py +++ b/tests/unit/test_link.py @@ -77,7 +77,7 @@ def test_fragments(self): @pytest.mark.parametrize( "yanked_reason, expected", - [(None, False), ("", True), ("there was a mistake", True),], + [(None, False), ("", True), ("there was a mistake", True)], ) def test_is_yanked(self, yanked_reason, expected): link = Link("https://example.com/wheel.whl", yanked_reason=yanked_reason,) diff --git a/tests/unit/test_network_download.py b/tests/unit/test_network_download.py index 415cde9b55d..9a93b2eeda2 100644 --- a/tests/unit/test_network_download.py +++ b/tests/unit/test_network_download.py @@ -108,7 +108,7 @@ def test_sanitize_content_filename__platform_dependent( @pytest.mark.parametrize( "content_disposition, default_filename, expected", - [('attachment;filename="../file"', "df", "file"),], + [('attachment;filename="../file"', "df", "file")], ) def test_parse_content_disposition(content_disposition, default_filename, expected): actual = parse_content_disposition(content_disposition, default_filename) diff --git a/tests/unit/test_network_utils.py b/tests/unit/test_network_utils.py index f8747879e4c..652bd24d42f 100644 --- a/tests/unit/test_network_utils.py +++ b/tests/unit/test_network_utils.py @@ -6,7 +6,7 @@ @pytest.mark.parametrize( - ("status_code", "error_type"), [(401, "Client Error"), (501, "Server Error"),] + ("status_code", "error_type"), [(401, "Client Error"), (501, "Server Error")] ) def test_raise_for_status_raises_exception(status_code, error_type): contents = b"downloaded" diff --git a/tests/unit/test_req_file.py b/tests/unit/test_req_file.py index 1af753730e3..138595e897f 100644 --- a/tests/unit/test_req_file.py +++ b/tests/unit/test_req_file.py @@ -139,7 +139,7 @@ def test_join_lines(self): assert expect == list(join_lines(lines)) def test_last_line_with_escape(self): - lines = enumerate(["line 1", "line 2 \\",], start=1) + lines = enumerate(["line 1", "line 2 \\"], start=1) expect = [ (1, "line 1"), (2, "line 2 "), @@ -572,7 +572,7 @@ def make_var(name): return "${{{name}}}".format(**locals()) env_vars = collections.OrderedDict( - [("GITHUB_TOKEN", "notarealtoken"), ("DO_12_FACTOR", "awwyeah"),] + [("GITHUB_TOKEN", "notarealtoken"), ("DO_12_FACTOR", "awwyeah")] ) with open(tmpdir.joinpath("req1.txt"), "w") as fp: diff --git a/tests/unit/test_req_uninstall.py b/tests/unit/test_req_uninstall.py index 946a84bd1a0..95e223a8390 100644 --- a/tests/unit/test_req_uninstall.py +++ b/tests/unit/test_req_uninstall.py @@ -236,7 +236,7 @@ def mock_walk(cls, root): def test_compress_for_rename(self, monkeypatch): paths = [ os.path.sep.join(p.split("/")) - for p in ["A/B/b.py", "A/B/D/c.py", "A/C/d.py", "A/E/f.py", "A/G/g.py",] + for p in ["A/B/b.py", "A/B/D/c.py", "A/C/d.py", "A/E/f.py", "A/G/g.py"] ] expected_paths = [ @@ -275,7 +275,7 @@ def make_stash(cls, tmpdir, paths): def test_stash(self, tmpdir): pathset, stashed_paths = self.make_stash( - tmpdir, ["A/B/", "A/C/d.py", "A/E/", "A/G/g.py",] + tmpdir, ["A/B/", "A/C/d.py", "A/E/", "A/G/g.py"] ) for old_path, new_path in stashed_paths: @@ -286,7 +286,7 @@ def test_stash(self, tmpdir): def test_commit(self, tmpdir): pathset, stashed_paths = self.make_stash( - tmpdir, ["A/B/", "A/C/d.py", "A/E/", "A/G/g.py",] + tmpdir, ["A/B/", "A/C/d.py", "A/E/", "A/G/g.py"] ) pathset.commit() @@ -297,7 +297,7 @@ def test_commit(self, tmpdir): def test_rollback(self, tmpdir): pathset, stashed_paths = self.make_stash( - tmpdir, ["A/B/", "A/C/d.py", "A/E/", "A/G/g.py",] + tmpdir, ["A/B/", "A/C/d.py", "A/E/", "A/G/g.py"] ) pathset.rollback() diff --git a/tests/unit/test_resolution_legacy_resolver.py b/tests/unit/test_resolution_legacy_resolver.py index 909126ec89f..764caa25590 100644 --- a/tests/unit/test_resolution_legacy_resolver.py +++ b/tests/unit/test_resolution_legacy_resolver.py @@ -134,7 +134,7 @@ def test_invalid_requires_python(self, caplog): "Invalid specifier: 'invalid'" ) - @pytest.mark.parametrize("metadata_name", ["METADATA", "PKG-INFO",]) + @pytest.mark.parametrize("metadata_name", ["METADATA", "PKG-INFO"]) def test_empty_metadata_error(self, caplog, metadata_name): """ Test dist.has_metadata() returning True and dist.get_metadata() diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 1b1bd8ab560..8ac8d426906 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -615,7 +615,7 @@ def test_glibc_version_string_confstr(self, monkeypatch): @pytest.mark.parametrize( "failure", - [lambda x: raises(ValueError), lambda x: raises(OSError), lambda x: "XXX",], + [lambda x: raises(ValueError), lambda x: raises(OSError), lambda x: "XXX"], ) def test_glibc_version_string_confstr_fail(self, monkeypatch, failure): monkeypatch.setattr(os, "confstr", failure, raising=False) diff --git a/tests/unit/test_utils_subprocess.py b/tests/unit/test_utils_subprocess.py index d2363163886..cd47e5169b8 100644 --- a/tests/unit/test_utils_subprocess.py +++ b/tests/unit/test_utils_subprocess.py @@ -301,7 +301,7 @@ def test_info_logging__subprocess_error(self, capfd, caplog): expected = ( None, - [("pip.subprocessor", ERROR, "Complete output (3 lines):\n"),], + [("pip.subprocessor", ERROR, "Complete output (3 lines):\n")], ) # The spinner should spin three times in this case since the # subprocess output isn't being written to the console. diff --git a/tests/unit/test_utils_temp_dir.py b/tests/unit/test_utils_temp_dir.py index daea1d0bba6..7c1b5172cde 100644 --- a/tests/unit/test_utils_temp_dir.py +++ b/tests/unit/test_utils_temp_dir.py @@ -89,7 +89,7 @@ def test_create_and_cleanup_work(): @pytest.mark.parametrize( - "name", ["ABC", "ABC.dist-info", "_+-", "_package", "A......B", "AB", "A", "2",] + "name", ["ABC", "ABC.dist-info", "_+-", "_package", "A......B", "AB", "A", "2"] ) def test_adjacent_directory_names(name): def names(): @@ -142,7 +142,7 @@ def names(): assert all(x.endswith(name) for x in some_names) -@pytest.mark.parametrize("name", ["A", "ABC", "ABC.dist-info", "_+-", "_package",]) +@pytest.mark.parametrize("name", ["A", "ABC", "ABC.dist-info", "_+-", "_package"]) def test_adjacent_directory_exists(name, tmpdir): block_name, expect_name = itertools.islice( AdjacentTempDirectory._generate_names(name), 2 diff --git a/tests/unit/test_utils_wheel.py b/tests/unit/test_utils_wheel.py index 0c2272388cc..0a477bf526f 100644 --- a/tests/unit/test_utils_wheel.py +++ b/tests/unit/test_utils_wheel.py @@ -104,7 +104,7 @@ def test_wheel_version_fails_on_no_wheel_version(): assert "missing Wheel-Version" in str(e.value) -@pytest.mark.parametrize("version", [("",), ("1.b",), ("1.",),]) +@pytest.mark.parametrize("version", [("",), ("1.b",), ("1.",)]) def test_wheel_version_fails_on_bad_wheel_version(version): with pytest.raises(UnsupportedWheel) as e: wheel.wheel_version(message_from_string("Wheel-Version: {}".format(version))) diff --git a/tests/unit/test_vcs.py b/tests/unit/test_vcs.py index e46be2c34cd..cb50fef5b27 100644 --- a/tests/unit/test_vcs.py +++ b/tests/unit/test_vcs.py @@ -430,7 +430,7 @@ def test_subversion__get_url_rev_and_auth(url, expected): # Git as a representative. @pytest.mark.parametrize( "username, password, expected", - [(None, None, []), ("user", None, []), ("user", hide_value("pass"), []),], + [(None, None, []), ("user", None, []), ("user", hide_value("pass"), [])], ) def test_git__make_rev_args(username, password, expected): """ @@ -560,7 +560,7 @@ def test_subversion__call_vcs_version_svn_not_installed(mock_run_command): Subversion().call_vcs_version() -@pytest.mark.parametrize("version", [(), (1,), (1, 8), (1, 8, 0),]) +@pytest.mark.parametrize("version", [(), (1,), (1, 8), (1, 8, 0)]) def test_subversion__get_vcs_version_cached(version): """ Test Subversion.get_vcs_version() with previously cached result. @@ -570,7 +570,7 @@ def test_subversion__get_vcs_version_cached(version): assert svn.get_vcs_version() == version -@pytest.mark.parametrize("vcs_version", [(), (1, 7), (1, 8, 0),]) +@pytest.mark.parametrize("vcs_version", [(), (1, 7), (1, 8, 0)]) @patch("pip._internal.vcs.subversion.Subversion.call_vcs_version") def test_subversion__get_vcs_version_call_vcs(mock_call_vcs, vcs_version): """ @@ -700,6 +700,4 @@ def test_switch(self): def test_update(self): self.svn.update(self.dest, hide_url(self.url), self.rev_options) - self.assert_call_args( - ["svn", "update", "--non-interactive", "/tmp/test",] - ) + self.assert_call_args(["svn", "update", "--non-interactive", "/tmp/test"]) diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py index a98992bffd5..53679853833 100644 --- a/tests/unit/test_wheel.py +++ b/tests/unit/test_wheel.py @@ -96,9 +96,7 @@ def test_get_entrypoints(console_scripts): ) wheel_zip = make_wheel( - "simple", - "0.1.0", - extra_metadata_files={"entry_points.txt": entry_points_text,}, + "simple", "0.1.0", extra_metadata_files={"entry_points.txt": entry_points_text}, ).as_zipfile() distribution = pkg_resources_distribution_for_wheel( wheel_zip, "simple", "" @@ -124,7 +122,7 @@ def test_get_entrypoints_no_entrypoints(): @pytest.mark.parametrize( "outrows, expected", [ - ([(u"", "", "a"), (u"", "", ""),], [("", "", ""), ("", "", "a"),]), + ([(u"", "", "a"), (u"", "", "")], [("", "", ""), ("", "", "a")]), ( [ # Include an int to check avoiding the following error: @@ -132,7 +130,7 @@ def test_get_entrypoints_no_entrypoints(): (u"", "", 1), (u"", "", ""), ], - [("", "", ""), ("", "", "1"),], + [("", "", ""), ("", "", "1")], ), ( [ @@ -140,7 +138,7 @@ def test_get_entrypoints_no_entrypoints(): (u"😉", "", 1), (u"", "", ""), ], - [("", "", ""), ("😉", "", "1"),], + [("", "", ""), ("😉", "", "1")], ), ], ) @@ -260,7 +258,7 @@ def prep(self, data, tmpdir): ... """ ), - metadata_updates={"Requires-Dist": ["peppercorn"],}, + metadata_updates={"Requires-Dist": ["peppercorn"]}, extra_files={ "sample/__init__.py": textwrap.dedent( ''' @@ -285,7 +283,7 @@ def main(): "top_level.txt": "sample\n", "empty_dir/empty_dir/": "", }, - extra_data_files={"data/my_data/data_file": "some data",}, + extra_data_files={"data/my_data/data_file": "some data"}, entry_points={ "console_scripts": ["sample = sample:main"], "gui_scripts": ["sample2 = sample:main"],