Skip to content

Commit

Permalink
Fix compat.get_session
Browse files Browse the repository at this point in the history
- Fixes #56

Signed-off-by: Dan Ryan <dan.ryan@canonical.com>
  • Loading branch information
techalchemy committed Feb 26, 2020
1 parent bb12127 commit c41c537
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions news/56.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion src/pip_shims/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"

0 comments on commit c41c537

Please sign in to comment.