diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 91052d6..15dc9ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,12 +5,12 @@ repos: - id: black - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v2.5.0 hooks: - id: flake8 - repo: https://github.com/asottile/seed-isort-config - rev: v1.9.4 + rev: v2.1.0 hooks: - id: seed-isort-config diff --git a/news/56.bugfix.rst b/news/56.bugfix.rst new file mode 100644 index 0000000..ccb7689 --- /dev/null +++ b/news/56.bugfix.rst @@ -0,0 +1 @@ +Fixed incorrect session creation via ``pip_shims.compat.get_session`` which inadvertently passed a tuple to pip when building a session instance. diff --git a/src/pip_shims/compat.py b/src/pip_shims/compat.py index 0206035..07bbec4 100644 --- a/src/pip_shims/compat.py +++ b/src/pip_shims/compat.py @@ -412,7 +412,7 @@ def get_session( assert isinstance(install_cmd_provider, (type, functools.partial)) install_cmd = install_cmd_provider() if options is None: - options = install_cmd.parser.parse_args([]) # type: ignore + options, _ = install_cmd.parser.parse_args([]) # type: ignore session = install_cmd._build_session(options) # type: ignore assert session is not None atexit.register(session.close) diff --git a/tests/test_instances.py b/tests/test_instances.py index b358201..1d31ca9 100644 --- a/tests/test_instances.py +++ b/tests/test_instances.py @@ -72,6 +72,7 @@ shim_unpack, url_to_path, ) +from pip_shims.compat import get_session STRING_TYPES = (str,) if sys.version_info < (3, 0): @@ -612,3 +613,9 @@ def test_stdlib_pkgs(): from pip_shims.shims import stdlib_pkgs assert "argparse" in stdlib_pkgs + + +def test_get_session(): + cmd = InstallCommand() + sess = get_session(install_cmd=cmd) + assert type(sess).__base__.__qualname__ == "Session"