Honor disable_numparse on the maxcolwidths wrap path (#428)#431
Open
assinscreedFC wants to merge 1 commit into
Open
Honor disable_numparse on the maxcolwidths wrap path (#428)#431assinscreedFC wants to merge 1 commit into
assinscreedFC wants to merge 1 commit into
Conversation
In _wrap_text_to_colwidths, the per-cell numparse flag was passed
positionally to _type() as the has_invisible argument:
_type(cell, numparse)
so _type() always used its default numparse=True. A number-ish but
unparseable cell (e.g. '80,443') was then cast to int and crashed with
ValueError, but only when maxcolwidths triggered the wrap path -- the
non-wrap path honored disable_numparse correctly.
Pass numparse as a keyword argument. This restores the fix from astanin#362
(regression of astanin#305 / astanin#428).
Fixes astanin#428
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #428 — a regression of #305 (originally fixed by #362), present on
masterand in v0.10.0.When
disable_numparse=Trueis combined withmaxcolwidths, a cell that looks number-ish but cannot be parsed (e.g.'80,443', a comma-separated port list) crashes:The same input works without
maxcolwidths:disable_numparseis honored on the non-wrap path but ignored on the wrap path.Root cause
In
_wrap_text_to_colwidths, the per-cellnumparseflag was passed positionally to_type():_type's signature is_type(string, has_invisible=True, numparse=True), sonumparsewas actually fillinghas_invisible, and_typealways ran with its defaultnumparse=True. The unparseable cell was then cast toint.Fix
Pass
numparseas a keyword argument:One-character-class change;
has_invisiblekeeps its default.Test plan
test_disable_numparse_honored_with_maxcolwidthsintest/test_regression.py.pytest test/— 366 passed, 1 skipped.ruff check/ruff format --check— clean.disable_numparseis not set).