Skip to content

Default an omitted fastnumbers patch component to zero - #209

Closed
harbinresearcher wants to merge 1 commit into
SethMMorton:mainfrom
harbinresearcher:codex/default-fastnumbers-patch-version
Closed

harbinresearcher wants to merge 1 commit into
SethMMorton:mainfrom
harbinresearcher:codex/default-fastnumbers-patch-version

Conversation

@harbinresearcher

Copy link
Copy Markdown

Closes #208.

The fastnumbers compatibility regex already accepts versions without a patch component, but converting the absent group with int(None) raises TypeError. Treat that component as zero, so 2.0 compares as 2.0.0 and the minimum-version guard retains its usual ImportError for an unsupported 1.9.

This preserves the regex and its existing prerelease comparison behavior. It adds no dependency or public API.

Validation:

  • New regression cases against the pristine source: 21 failed, 3 passed. All 24 pass after the fix. Cases cover explicit/omitted patch values, alpha/beta spellings, and three minimum-version thresholds, including (5, 0, 1).
  • Full suites with the configured Hypothesis profile: Windows CPython 3.12.14 with fastnumbers 5.2.0, and Linux CPython 3.9.25 / 3.14.8 without optional accelerators, each 363 → 387 passed. Python 3.14 retains the same existing Unicode-table warning.
  • The documented how-it-works, README/example, and source-module doctest commands passed on both Linux versions and on patched Windows.
  • Both pristine and patched Linux checkouts pass Ruff format, strict mypy, and Sphinx warnings-as-errors. Ruff 0.17.1 lint reports the same 39 existing findings on each; structured comparison found no added findings. Broad lint repairs remain with Fix the Ruff errors reported in #200 #203. Windows mypy also reports an unused ignore on the unchanged natsort.py:695.
  • Isolated sdist/wheel build and twine check passed. Installing the built wheel into a separate target, verifying the actual imported module, and running the target test file gave 39 passed.
  • Independent automated read-only review found no actionable issues, reran the 39 target tests, and verified malformed versions retain ValueError.

To exercise the import path, isolated child processes used real fastnumbers 5.2.0 with only its reported version string temporarily changed to 2.0 or 5.0. They fail during import natsort on the original code and sort normally after the fix. These are simulated shortened version strings: no published fastnumbers release reporting them has been identified, and no deployment failure is claimed.

AI assistance was used for investigation, implementation, tests, automated review, and this description. PyICU, macOS, FreeBSD, and the full interpreter matrix were not tested locally. This is a parser consistency fix, not a general PEP 440 implementation.

@SethMMorton

Copy link
Copy Markdown
Owner

This seem like a solution looking for a problem. Is this a real problem actually found in real code, or is this a contrived example?

@harbinresearcher

Copy link
Copy Markdown
Author

This is a constructed version-string example, not a failure found in real application code. I reproduced it by substituting a short fastnumbers.__version__; I have not identified a released fastnumbers build that reports such a value. The release tags I checked use three version components.

The optional regex group suggested a parser inconsistency, but that does not establish an actual compatibility problem. I'll withdraw this PR and the associated report rather than ask you to maintain a change without a demonstrated need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optional fastnumbers patch version raises TypeError during comparison

2 participants