GH-142035: Fix wrapping of colorized argparse help text#154634
GH-142035: Fix wrapping of colorized argparse help text#154634savannahostrowski merged 4 commits into
Conversation
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
|
Thanks @savannahostrowski for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
Sorry @savannahostrowski, I had trouble completing the backport. |
|
Sorry @savannahostrowski, I had trouble completing the backport. |
|
Thanks @savannahostrowski for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15. |
…GH-154634) (cherry picked from commit 998fc4a) Co-authored-by: Savannah Ostrowski <savannah@python.org> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
|
GH-154644 is a backport of this pull request to the 3.15 branch. |
|
Thanks @savannahostrowski for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Thanks @savannahostrowski for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15. |
…GH-154634) (cherry picked from commit 998fc4a) Co-authored-by: Savannah Ostrowski <savannah@python.org> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
…GH-154634) (cherry picked from commit 998fc4a) Co-authored-by: Savannah Ostrowski <savannah@python.org> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
|
GH-154645 is a backport of this pull request to the 3.14 branch. |
|
Sorry @savannahostrowski, I had trouble completing the backport. |
|
GH-154646 is a backport of this pull request to the 3.15 branch. |
…4634) (#154644) GH-142035: Fix wrapping of colorized argparse help text (GH-154634) (cherry picked from commit 998fc4a) Co-authored-by: Savannah Ostrowski <savannah@python.org> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
|
Geez, not sure what was up with Miss Islington here but what a mess 🙃 |
|
ANSI color sequences in interpolated
argparsehelp values were counted as visible characters bytextwrap, causing colored and uncolored help to wrap differently.This was a bit tricky but this updates
HelpFormatter._split_lines()to wrap the decolored text and use those lines as the source of truth. When wrapping occurs between complete words, the corresponding colored words are reconstructed. Iftextwrapsplits a long or hyphenated word, the correctly wrapped plain lines are used instead.