Repository navigation
Decide the fate of undocumented script behavior of some modules #93096
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on May 23, 2022 - addedtestsTests in the Lib/test dirTests in the Lib/test dirdocsDocumentation in the Doc dirDocumentation in the Doc dir
on May 23, 2022 pprintalso has a rudimentary performance test. See #92546 for a bug, where it wasn't being tested. If we really care about this performance metric, it should be moved to a proper benchmark.@ericvsmith Thank you, I've added it to the list.
I wasn’t aware of this ticket!
Script feature of stdlib modules have been discussed a few times in various PRs, as well as this forum thread: https://discuss.python.org/t/command-line-interface-for-the-random-module/51304I suggest that discuss is a better place to reach a decision that a ticket.
For deciding whether to expose the cli or not is probably worth a DPO thread, but deciding whether to remove or not the internal options meant for self-testing may be discussed in an issue directly I think (as we would just move self-tests/doctests to unittests and/or run them directly).
13 remaining items
ping @hugovk as author of
--testflag inrandomcliIn discuss you suggested opening a new issue but I think this issue is more appropriate. Since the discussion was closed I suggest that if anyone has objections, they write here, but I have not seen any objections yet
If you don't mind such a change, then I will open a PR
sorry, i didn't wait for you because i found that we already removed such thing for
pprintmodule (PR #94613)
these tests are moving to pyperformance, see #131144Reacted by Hugo van Kemenade- added a commit that references this issue
on Mar 14, 2025 We have modules that don't have the
-h/--helpflag, for example:fileinput(no docs, run demo)ftplib(no docs, have help message, but it only prints without any flags)filecmp(no docs)poplib(no docs, run demo)pyclbr(no docs)quopri(no docs)tabnanny(no docs)site(have docs and help message, but it only prints when there is error)
The problem is that these CLIs expect some arguments, but nowhere is it said which ones! (no docs, no help messages)
I don't suggest adding documentation for all of them, as this would make them public and this could raise other questions.
I think that users to not have to look into source code, it would be convenient to have a help message and a flag to print itI don't think help message is required for
asyncio,this,turtledemoor something similar@vstinner does it make sense to open issue to send PRs?
EDIT: I think this will add consistency to the behavior of CLI modules
- added a commit that references this issue
on Mar 17, 2025 - added 4 commits that reference this issue
on Mar 17, 2025 - added a commit that references this issue
on Apr 8, 2025 - added a commit that references this issue
on Apr 8, 2025
There are three dozens of standard modules that can be called via
python -mand their documentation doesn't mention it. They can be grouped into five categories:kind of smoke tests:
performs stdin:latin1 → utf-8 → latin1 → stdout passthroughedit: it just wraps stdin and stdout then just exits the script (gh-93096: Removepython -m codecs#94233)python -m pprintpyperformance#222)full-fledged crossplatform utils for admin-like users and small automation:
pythonbut allows to useawaitin top-level script codemimetypesCLI tool public #93097).netrcfor a current userWindows-10-10.0.19044-SP0; can be useful in automationboth:
base64 -tencodes/decodesAladdin:open sesameand tests if the result is the same as the original (gh-93096: Removepython -m base64 -t#94230)demos with no real world application:
getopt: just passes arguments toThe module is no longer maintained after gh-106535: Soft deprecate the getopt module #105735getopt()shlex()and prints the list into stdoutcomplex matter; better leave untouched:
Eggs and to-be-removed modules aren't listed.
We need to decide what to do with all these undocumented categories.
I propose the following:
testmodule with deduplicationCommand-Line Usageinto the docs like in https://docs.python.org/3/library/ast.html#command-line-usage or https://docs.python.org/3/library/trace.html#command-line-usageLinked PRs
-tand-vflags frompickletoolscli #131039-tand-vflags frompicklecli #131068test_pickle#131069test_pickle(GH-131069) #131080test_pickle(GH-131069) #131081pickleCLI #131097difflib#131099heapq#131130test_itertools#131133test_itertools(GH-131133) #131136test_itertools(GH-131133) #131137randombenchmark into pyperformance #131144pickletoolsCLI #131273test_mimetypes.test_guess_type_conflicting_with_mimetypes#131408test_mimetypes.test_invocation_errortests on iOS ARM64 #132266