Skip to content

pipx run hatch run lint causes an "unexpected JSON" error #1939

@kratsg

Description

@kratsg

Describe the bug

When I use pipx to run hatch run lint like below, I get an unexpected JSON error

root@2986bb1812e5:/debug# pipx run hatch run lint
error: Received some unexpected JSON from https://pypi.org/simple/tbump/
  Caused by: invalid type: string ">=\"3.5\"", expected a borrowed string at line 1 column 19557

How to reproduce

See the attached pyproject.txt (rename as pyproject.toml), and create the minimal directory structure:

mkdir -p module_qc_tools
touch module_qc_tools/__init__.py

and see following output:

$ docker run -it --rm -v $PWD:/debug -w /debug python:3.11-buster bash
root@93f591419ead:/debug# python3 -m pip install -U pipx pip
Collecting pipx
  Downloading pipx-1.7.1-py3-none-any.whl (78 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.7/78.7 kB 5.4 MB/s eta 0:00:00
Requirement already satisfied: pip in /usr/local/lib/python3.11/site-packages (23.1.2)
Collecting pip
  Downloading pip-25.0.1-py3-none-any.whl (1.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 20.5 MB/s eta 0:00:00
Collecting argcomplete>=1.9.4 (from pipx)
  Downloading argcomplete-3.6.0-py3-none-any.whl (43 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.8/43.8 kB 24.6 MB/s eta 0:00:00
Collecting packaging>=20 (from pipx)
  Downloading packaging-24.2-py3-none-any.whl (65 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.5/65.5 kB 34.0 MB/s eta 0:00:00
Collecting platformdirs>=2.1 (from pipx)
  Downloading platformdirs-4.3.6-py3-none-any.whl (18 kB)
Collecting userpath!=1.9,>=1.6 (from pipx)
  Downloading userpath-1.9.2-py3-none-any.whl (9.1 kB)
Collecting click (from userpath!=1.9,>=1.6->pipx)
  Downloading click-8.1.8-py3-none-any.whl (98 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.2/98.2 kB 30.7 MB/s eta 0:00:00
Installing collected packages: platformdirs, pip, packaging, click, argcomplete, userpath, pipx
  Attempting uninstall: pip
    Found existing installation: pip 23.1.2
    Uninstalling pip-23.1.2:
      Successfully uninstalled pip-23.1.2
Successfully installed argcomplete-3.6.0 click-8.1.8 packaging-24.2 pip-25.0.1 pipx-1.7.1 platformdirs-4.3.6 userpath-1.9.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@93f591419ead:/debug# python3 -m pip freeze --local
argcomplete==3.6.0
click==8.1.8
packaging==24.2
pipx==1.7.1
platformdirs==4.3.6
userpath==1.9.2
root@93f591419ead:/debug# pipx run --verbose hatch run lint
pipx >(setup:1110): pipx version is 1.7.1
pipx >(setup:1111): Default python interpreter is '/usr/local/bin/python3.11'
pipx >(mkdir:76): creating directory /root/.local/share/pipx/venvs
pipx >(mkdir:76): creating directory /root/.local/bin
pipx >(mkdir:76): creating directory /root/.local/share/man
pipx >(mkdir:76): creating directory /root/.cache/pipx
pipx >(mkdir:76): creating directory /root/.local/share/pipx/py
pipx >(run_package:162): venv location is /root/.cache/pipx/ff310e08bfd1a86
pipx >(package_name_from_spec:378): Determined package name: hatch
pipx >(package_name_from_spec:379): Package name determined in 0.0s
pipx >(create_venv:164): Creating virtual environment
creating virtual environment...
pipx >(run_subprocess:175): running /usr/local/bin/python3.11 -m venv --without-pip /root/.cache/pipx/ff310e08bfd1a86
creating shared libraries...
pipx >(run_subprocess:175): running /usr/local/bin/python3.11 -m venv --clear /root/.local/share/pipx/shared
pipx >(run_subprocess:175): running <checking pip's availability>
pipx >(upgrade:119): Upgrading shared libraries in /root/.local/share/pipx/shared
upgrading shared libraries...
pipx >(run_subprocess:175): running /root/.local/share/pipx/shared/bin/python -m pip --no-input --disable-pip-version-check install --force-reinstall --upgrade pip >= 23.1
pipx >(run_subprocess:175): running /root/.cache/pipx/ff310e08bfd1a86/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:175): running /root/.local/share/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:175): running /root/.cache/pipx/ff310e08bfd1a86/bin/python --version
pipx >(_parsed_package_to_package_or_url:139): cleaned package spec: hatch
pipx >(install_package:247): Installing hatch
installing hatch...
pipx >(run_subprocess:175): running /root/.cache/pipx/ff310e08bfd1a86/bin/python -m pip --no-input install hatch
pipx >(run_subprocess:175): running <fetch_info_in_venv commands>
pipx >(get_venv_metadata_for_package:351): get_venv_metadata_for_package: 151ms
pipx >(_parsed_package_to_package_or_url:139): cleaned package spec: hatch
pipx >(run_subprocess:175): running /root/.cache/pipx/ff310e08bfd1a86/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:175): running /root/.cache/pipx/ff310e08bfd1a86/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(exec_app:375): exec_app: /root/.cache/pipx/ff310e08bfd1a86/bin/hatch run lint
error: Received some unexpected JSON from https://pypi.org/simple/tbump/
  Caused by: invalid type: string ">=\"3.5\"", expected a borrowed string at line 1 column 19557

Expected behavior

It should have been able to run without crashing. Unclear what's going on here.

pyproject.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions