Skip to content

Warnings Produced when Using a PEP 440 Local Version #7035

@bryanfraschetti

Description

@bryanfraschetti

Summary

When packaging urllib3 with a local version identifier, eg. 2.0.7+local.1, and installing requests the check_compatibility function returns warnings after hitting the following traceback. While this only produces a warning, it can be problematic in CIs that are configured to treat warnings as failures

/usr/local/lib/python3.12/dist-packages/requests/__init__.py:113: RequestsDependencyWarning: urllib3 (2.0.7+local.1) or chardet (None)/charset_normalizer (3.4.2) doesn't match a supported version!
Traceback (most recent call last):
File "/usr/local/lib/python3.12/dist-packages/requests/__init__.py", line 109, in <module>
check_compatibility(
File "/usr/local/lib/python3.12/dist-packages/requests/__init__.py", line 67, in check_compatibility
major, minor, patch = urllib3_version # noqa: F811
^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 3)

Essentially, the . in the local version (+local.1) is split during urllib3_version = urllib3_version.split("."), which results in urllib3_version having four elements instead of the three that are expected, and then the code attempts to destructure the four elements into three variables, causing an exception to be thrown.

Expected Result

The expectation was that the version with the local specifier would pass the compatibility check. I think that we can consider only the public version identifier part of the string for the compatibility check and that the local version part of the string could be ignored

Actual Result

The compatibility check throws an exception, resulting in warnings.

Reproduction Steps

python3 -m venv venv
source venv/bin/activate
pip install requests urllib3
python3

Python 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib3
>>> from requests import check_compatibility
>>> urllib3.__version__ = "2.0.7+local.1"
>>> check_compatibility(
...     urllib3_version=urllib3.__version__,
...     chardet_version=None,
...     charset_normalizer_version="3.2.0",
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bryan/requests-repro/venv/lib/python3.12/site-packages/requests/__init__.py", line 67, in check_compatibility
    major, minor, patch = urllib3_version  # noqa: F811
    ^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 3)

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