Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide the fate of undocumented script behavior of some modules #93096

Open
4 of 27 tasks
arhadthedev opened this issue May 23, 2022 · 9 comments
Open
4 of 27 tasks

Decide the fate of undocumented script behavior of some modules #93096

arhadthedev opened this issue May 23, 2022 · 9 comments
Labels
docs Documentation in the Doc dir tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@arhadthedev
Copy link
Member

arhadthedev commented May 23, 2022

There are three dozens of standard modules that can be called via python -m and their documentation doesn't mention it. They can be grouped into five categories:

  • kind of smoke tests:

  • full-fledged crossplatform utils for admin-like users and small automation:

    • asyncio: like python but allows to use await in top-level script code
    • cProfile, profile: runs a script under the profiler
    • encodings.rot_13: a stream converter
    • filecmp: a crossplatform file comparison utility
    • fileinput: prints specified files one by another annotating lines with their source
    • http.server: makes a directory available as a site; useful to quickly test a static site with relative links
    • mimetypes: useful for batch processing of files (maybe) (gh-93096: Make mimetypes CLI tool public #93097)
    • modulefinder: the objdump but for Python source files
    • netrc: prints content of .netrc for a current user
    • pdb
    • platform: returns a single line like Windows-10-10.0.19044-SP0; can be useful in automation
    • quopri: a stream converter
    • tabnanny
    • wsgiref.simple_server - the same as http.server but for APIs; pases a single request and exits
  • both:

  • demos with no real world application:

    • curses.textpad: shows an input area; when a user closes it, prints the text back
    • ftplib: a simple one-pass FTP downloader (uses ~/.netrc for login)
    • getopt: just passes arguments to getopt() The module is no longer maintained after gh-106535: Soft deprecate the getopt module #105735
    • imaplib: sending emails to a dead end has no sence but can be used to check if a email client works or got broken
    • shlex: parses stdin using shlex() and prints the list into stdout
    • smtplib: a simple e-mail client
    • xmlrpc.server: serves a datetime service
  • complex matter; better leave untouched:

    • idlelib.*
    • tkinter.*
    • turtledemo.*
    • pstats

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:

Linked PRs

@arhadthedev arhadthedev added the type-feature A feature request or enhancement label May 23, 2022
@erlend-aasland erlend-aasland added tests Tests in the Lib/test dir docs Documentation in the Doc dir labels May 23, 2022
@ericvsmith
Copy link
Member

pprint also 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.

@arhadthedev
Copy link
Member Author

@ericvsmith Thank you, I've added it to the list.

miss-islington pushed a commit that referenced this issue Jul 25, 2022
This PR couples with python/pyperformance#222 and supersedes #92560. Inspired by #93096 (comment).

Automerge-Triggered-By: GH:ericsnowcurrently
arhadthedev added a commit to arhadthedev/cpython that referenced this issue Aug 1, 2022
arhadthedev added a commit to arhadthedev/cpython that referenced this issue Aug 1, 2022
@donBarbos
Copy link
Contributor

@picnixz based on your comment i suggest to get rid of t and v flags in pickle and pickletools modules and put tests in common place

@merwok
Copy link
Member

merwok commented Mar 10, 2025

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/51304

I suggest that discuss is a better place to reach a decision that a ticket.

@picnixz
Copy link
Member

picnixz commented Mar 10, 2025

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).

@merwok
Copy link
Member

merwok commented Mar 10, 2025

I agree on this point – self-tests are better removed.

But the ticket is also about other categories of scripts, which should not be decided by only a few devs here IMO.

serhiy-storchaka pushed a commit that referenced this issue Mar 11, 2025
…131080)

(cherry picked from commit 3bb20d1)

Co-authored-by: donBarbos <donbarbos@proton.me>
vstinner pushed a commit that referenced this issue Mar 11, 2025
Remove `python -m pickletools -t`
vstinner pushed a commit that referenced this issue Mar 11, 2025
* Remove `python -m pickle -t`

* Revert adding doctest to unittests
@donBarbos
Copy link
Contributor

ping @hugovk as author of --test flag in random cli

In 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

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 12, 2025
(cherry picked from commit 15a8412)

Co-authored-by: donBarbos <donbarbos@proton.me>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 12, 2025
(cherry picked from commit 15a8412)

Co-authored-by: donBarbos <donbarbos@proton.me>
vstinner pushed a commit that referenced this issue Mar 12, 2025
gh-93096: Load doctests in `test_itertools` (GH-131133)
(cherry picked from commit 15a8412)

Co-authored-by: donBarbos <donbarbos@proton.me>
vstinner pushed a commit that referenced this issue Mar 12, 2025
gh-93096: Load doctests in `test_itertools` (GH-131133)
(cherry picked from commit 15a8412)

Co-authored-by: donBarbos <donbarbos@proton.me>
@donBarbos
Copy link
Contributor

ping @hugovk as author of --test flag in random cli

In 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 pprint module (PR #94613)
these tests are moving to pyperformance, see #131144

hugovk added a commit that referenced this issue Mar 13, 2025
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
vstinner added a commit that referenced this issue Mar 14, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@donBarbos
Copy link
Contributor

donBarbos commented Mar 16, 2025

We have modules that don't have the -h/--help flag, 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 it

I don't think help message is required for asyncio, this, turtledemo or 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

plashchynski pushed a commit to plashchynski/cpython that referenced this issue Mar 17, 2025
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
plashchynski pushed a commit to plashchynski/cpython that referenced this issue Mar 17, 2025
plashchynski pushed a commit to plashchynski/cpython that referenced this issue Mar 17, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
plashchynski pushed a commit to plashchynski/cpython that referenced this issue Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

6 participants