Repository navigation
Remove Python 2 utilities and little used utilities #3481
Description
Activity
@kdeldycke @davidism Any others to consider?
get_binary_streamandget_text_streamare genuinely Python 2/3-era shims for thesys.stdinvssys.stdin.buffersplit, so fair game to deprecate them. Can help identified other Python 2 left-over as suspected by @davidism at #3482 (comment)wrap_textis used internally a lot forHelpFormatter. Also used by @janluke in https://github.com/janluke/cloup/blob/d53d04f51846e3dbfe6a1b97ad677bfc5cdda47f/cloup/formatting/_formatter.py#L239-L240. What do you want to replace it with?I have doubt about
getchar. Is there a multi-platform equivalent in thestdlib?Reacted by Gianluca Gippetto- addedpromptInteractive input and confirmationInteractive input and confirmationhelp outputHelp text formatting, layout, and --help renderingHelp text formatting, layout, and --help rendering
on May 22, 2026 Not everything in utilities is compat stuff for Python 2. Pretty sure we use
getcharbecause there's no built-in way to get a single character input (without pressing Enter) cross-platform.Reacted by Kevin DeldyckeUpdated the issue. Plan to do a GitHub search for how much things are used. I got these from talking with people at Pycon, so just soliciting input. I am mainly concerned with reducing the public api. People are free to vendor the code, I just want to be sure it is really used if we keep it around. A fair amount of utilities have little to no test coverage, so there is maintenance work to be done if we want to keep them around.
https://sourcegraph.com/search is a good resource for that, as long as you remember to exclude forks and vendored copies of Click itself (and Typer). Here's a starting search for
getchar: https://sourcegraph.com/search?q=context:global+lang:Python+-path:click+-path:typer+click.getchar&patternType=keyword&sm=0 but you also need to search forpausewhich uses it. There's definitely some use out there. Not sure if it's significant enough to justify, especially if things like prompt-toolkit https://python-prompt-toolkit.readthedocs.io/en/3.0.52/pages/asking_for_input.html#reading-keys-from-stdin-one-key-at-a-time-but-without-a-prompt and textual exist.Reacted by Kevin DeldyckeRemoving colorama in #3505, I was reminded just how many ways click inspects and wraps the input and output streams. I have a feeling all of that can be removed now. The standard streams are always text. Pretty sure the encoding is always UTF-8 on all platforms now. Last year I went through and deprecated then removed all support for bytes in Werkzeug, and didn't encounter any subsequent problems. We could probably do something similar in Click: remove the behind-the-scenes wrappers, deprecate passing binary streams (users can wrap them in
TextIOWrapperthemselves if they have some special stream), and then remove in 9.Removing colorama in #3505, I was reminded just how many ways click inspects and wraps the input and output streams. I have a feeling all of that can be removed now. The standard streams are always text. Pretty sure the encoding is always UTF-8 on all platforms now. Last year I went through and deprecated then removed all support for bytes in Werkzeug, and didn't encounter any subsequent problems. We could probably do something similar in Click: remove the behind-the-scenes wrappers, deprecate passing binary streams (users can wrap them in
TextIOWrapperthemselves if they have some special stream), and then remove in 9.I like that plan. Also a bit appalled by all the stream and I/O dance I had to go through in the last couple of releases just to make things work. I mainly apply fixes locally on that front in fear of breaking something. So any streamlining attempt is welcome and I think the time is right: we have the maintainership momentum and enough accumulated tests for refactoring part of Click in 8.x before 9.0. Feel free to attempt a PR and I'll test it! :)
Given #3676 , I guess the milestone change to 9.0.0 is just the blast radius of the recent
main<->stabledance. So I retarget this to 8.5.0 unless an explicit decision is made.- linked a pull request that will close this issueMark clearly functions private status. Deprecated Python 2 utilities. #3695
on Jul 16, 2026 Decided after thinking for a bit. The real concern with utilities is continuing maintenance burden that blocks future dev, but there have been few if any issues with utilities in the last few years, so just going to leave them except the two clearly python 2 ones. On the surface they provide at least some utility. The test coverage for them is not great, so getting them to full test coverage can be a project that newer contributors can add meaningful value.
Reacted by David Lord- locked as resolved and limited conversation to collaborators
on Aug 1, 2026
Python2-centric utilities:
get_binary_streamget_text_streamLittle used Utilities:
wrap_textgetcharIn the interest of making more time to focus on core click details, these utilities are planned to be deprecated in the next feature release, and removed from the public api in one after. If any of these are critical to your uses, please explain below, and we may consider other options.