GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update function signatures to use `*` and `/` as needed · Issue #131885 · python/cpython

Update function signatures to use * and / as needed #131885

New issue
Copy link
New issue
Copy link
Open
Open
Update function signatures to use * and / as needed#131885
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@ekohilas
ekohilas
opened on Mar 30, 2025
Issue body actions

Documentation

Caution

For new contributors, please do not consider this issue as an "easy" one. While the changes may seem mechanical, they are not necessarily trivial as this requires to know what really happens (both at a Python and a C level).

This is tracks cases where changes need to be made to enact the Editorial Board's decision for function signature markup.

  • builtins:
    • min()
    • max()
    • range()
    • map()
  • methods on builtins:
    • dict.get(), dict.setdefault()

See also:

  • https://discuss.python.org/t/editorial-board-decisions/58580
  • gh-129667: Update annotation in documentation #129669 (comment)
  • https://discuss.python.org/t/81003
  • https://devguide.python.org/documentation/style-guide/#function-signatures
  • https://discuss.python.org/t/58750

Linked PRs

  • gh-131885: Updates docs to make max and min iterable param positional only #131868
  • gh-131885: simplify function signatures in the cmath module #131886
  • gh-131885: Document that dict.setdefault takes no keyword arguments #128208
  • [3.13] gh-131885: Document that dict.setdefault and dict.get take no keyword arguments (GH-128208) #131893
  • [3.12] gh-131885: Document that dict.setdefault and dict.get take no keyword arguments (GH-128208) #131894
  • gh-131885: Use positional-only markers for the decimal module #131990
  • gh-131885: Document / for codecs functions #131992
  • gh-131885: Document * for code.InteractiveConsole #132029
  • gh-131885: update documented signatures for csv.{writer,reader} #136085
  • [3.14] gh-131885: Update documented signatures for csv.{writer,reader} (GH-136085) #136120
  • [3.13] gh-131885: Update documented signatures for csv.{writer,reader} (GH-136085) #136121
  • [3.14] gh-131885: Use positional-only markers for max() and min() (GH-131868) #137656
  • [3.13] gh-131885: Use positional-only markers for max() and min() (GH-131868) #137657
  • [3.14] gh-131885: Use positional-only markers for the decimal module (GH-131990) #137902
  • [3.13] gh-131885: Use positional-only markers for the decimal module (GH-131990) #137904
  • gh-131885: Update location of positional-only parameter indicator for eval and exec in the documentation #139978
  • gh-131885: Update unicodedata function signatures to use / #140270
  • gh-142349: Clarify lazy import filters have positional-only parameters #144856
  • gh-131885: Use real signatures in the zlib docs #156179
  • [3.13] gh-131885: Use real signatures in the zlib docs (GH-156179) #156267
  • [3.15] gh-131885: Use real signatures in the zlib docs (GH-156179) #156268
  • [3.14] gh-131885: Use real signatures in the zlib docs (GH-156179) #156269

Activity

Next
  1. ekohilas
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Mar 30, 2025
  2. github-project-automation
    added this to docs issueson Mar 30, 2025
  3. github-project-automation
    moved this to Todo in docs issueson Mar 30, 2025
  4. skirpichev
    added a commit that references this issue on Mar 30, 2025

    pythongh-131885: simplify function signatures in the cmath module

    6548be0
  5. picnixz
    added a commit that references this issue on Mar 30, 2025

    gh-131885: Document that `dict.setdefault` and `dict.get` take no key…

    edfbd8c
  6. miss-islington
    added 2 commits that reference this issue on Mar 30, 2025

    pythongh-131885: Document that `dict.setdefault` and `dict.get` take …

    b5d3303

    pythongh-131885: Document that `dict.setdefault` and `dict.get` take …

    000b076
  7. picnixz
    added 2 commits that reference this issue on Mar 30, 2025

    [3.13] gh-131885: Document that `dict.setdefault` and `dict.get` take…

    2570896

    [3.12] gh-131885: Document that `dict.setdefault` and `dict.get` take…

    525eddf
  8. chris-eibl commented on Mar 30, 2025

    @chris-eibl
    chris-eibl
    on Mar 30, 2025
    Member
    More actions

    Regarding range, please see also #125897.

    Reacted by Evan Kohilas
  9. skirpichev commented on Apr 1, 2025

    @skirpichev
    skirpichev
    on Apr 1, 2025
    Member
    More actions

    My 2c on how this can be addressed.

    First, probably we shouldn't just mechanically change docs to reflect actual signatures. I trust @rhettinger teaching experience that slash/star-enabled signatures are less readable for newcomers. On another hand, IMO such signatures for C-coded functions usually seems to be artifacts of lacking the AC in past. Now we can use positional-or-keyword arguments in C and leave boilerplate code to the AC. Why not do this? Then e.g. we can use plain-and-simple len(obj) in documentation, instead of len(obj, /). Note that first form preferred also by some Python implementations (e.g. PyPy).

    The price is some performance degradation (see #131886), which might be AC bug. Also, argument names will be part of the API.

    Second, I think that EB decision covers only sphinx docs, @nedbat ?

    If so, we also have docstrings for C-coded functions, where in some cases function signatures are documented by some non-Python syntax, nowhere (i.e. in docs) actually documented. min/max functions are examples. What we should do here?

    Proper solution, probably, requires solving #73536. But that seems to be rather an issue for the inspect module. I think that already now we can start fixing such docstrings to use multiple signatures (each being a valid Python function signature!), just as sphinx docs. So, the outcome for e.g. max() will be (as in #117671, merge conflicts fixed in skirpichev#7):

    >>> help(max)
    Help on built-in function max in module builtins:
    
    max(iterable, /, *, key=None)
    max(iterable, /, *, default, key=None)
    max(arg1, arg2, /, *args, key=None)
        With a single iterable argument, return its biggest item. The
        default keyword-only argument specifies an object to return if
        the provided iterable is empty.
        With two or more positional arguments, return the largest argument.
    

    Sure, we can invent a more dense syntax for such signatures. But I doubt it worth: 1) new syntax will require an explanation 2) save us line or two in each case, at maximum.

  10. ekohilas commented on Apr 11, 2025

    @ekohilas
    ekohilas
    on Apr 11, 2025
    ContributorAuthor
    More actions

    I trust @rhettinger teaching experience that slash/star-enabled signatures are less readable for newcomers.

    I could understand why that would be the case previously, if you didn't know what / meant!
    I would think now with the tooltips present on mouseover for * and /, that would no longer be the case, as newcomers could dig into what that means.
    As it stands, the lack of / and * in signatures is worse, because users that have seen or understood different types of argument usage would be confused why a function behaves as if it has a / but isn't documented as such.

    artifacts of lacking the AC in past.

    Could you clarify what AC means here?

    we also have docstrings for C-coded functions, where in some cases function signatures are documented by some non-Python syntax, nowhere (i.e. in docs) actually documented. min/max functions are examples. What we should do here?

    max(iterable, /, *, key=None)
    max(iterable, /, *, default, key=None)
    max(arg1, arg2, /, *args, key=None)
    With a single iterable argument, return its biggest item. The
    default keyword-only argument specifies an object to return if
    the provided iterable is empty.
    With two or more positional arguments, return the largest argument.
    Sure, we can invent a more dense syntax for such signatures. But I doubt it worth: 1) new syntax will require an explanation 2) save us line or two in each case, at maximum.

    Yes this is great!
    If docstrings are used as docs, they could be the same as the docs and signatures in the docs themselves?
    No need for having to define the undocumented syntax already used, and give newcomers another thing to learn.

  11. skirpichev commented on Apr 11, 2025

    @skirpichev
    skirpichev
    on Apr 11, 2025
    Member
    More actions

    I would think now with the tooltips present on mouseover for * and /

    There is no tooltips in help() output.

    Could you clarify what AC means here?

    https://devguide.python.org/development-tools/clinic/

    If docstrings are used as docs, they could be the same as the docs and signatures in the docs themselves?

    In general, sphinx docs and docstrings are different. Later less verbose, miss examples, etc. But wrt functions signatures they could be same and, probably, should.

  12. vstinner
    added a commit that references this issue on Apr 14, 2025

    gh-131885: Document `/` for `codecs` functions (#131992)

    bd47ec9
  13. ZeroIntensity
    added a commit that references this issue on Jun 30, 2025

    gh-131885: Update documented signatures for `csv.{writer,reader}` (GH…

    75f4059
  14. 22 remaining items

  15. vstinner
    added a commit that references this issue on Oct 30, 2025

    gh-131885: Update unicodedata function signatures to use `/` (#140270)

    2a90426
  16. vstinner commented on Oct 30, 2025

    @vstinner
    vstinner
    on Oct 30, 2025
    Member
    More actions

    What's the status of this issue? Can it be closed?

  17. StanFromIreland
    marked Clarify documentation of positional-only default values #67926 as a duplicate of this issue on Oct 30, 2025
  18. ekohilas commented on Oct 30, 2025

    @ekohilas
    ekohilas
    on Oct 30, 2025 via email
    ContributorAuthor
    More actions
    Thanks for checking in. Will review the current progress and update with the status.(Unless a new issue should be made for any other related changes)On 30 Oct 2025, at 6:41 am, Victor Stinner ***@***.***> wrote:vstinner left a comment (python/cpython#131885) What's the status of this issue? Can it be closed? —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
  19. skirpichev commented on Oct 30, 2025

    @skirpichev
    skirpichev
    on Oct 30, 2025
    Member
    More actions

    Can it be closed?

    There are open pull requests.

    And there are many stdlib modules (e.g. math or cmath), for which the issue is still valid and should be solved one way or another.

  20. vstinner
    added a commit that references this issue on Oct 31, 2025

    gh-131885: Document `*` for `code.InteractiveConsole` (#132029)

    e733dc9
  21. vstinner commented on Oct 31, 2025

    @vstinner
    vstinner
    on Oct 31, 2025
    Member
    More actions

    I merged #132029 PR.

    Reacted by Sergey B Kirpichev
  22. skirpichev
    marked operator library and inspect.signature clarity: "a" versus "obj"? #141334 as a duplicate of this issue on Nov 10, 2025
  23. skirpichev commented on Nov 10, 2025

    @skirpichev
    skirpichev
    on Nov 10, 2025
    Member
    More actions

    Operator module: #141334

  24. StanFromIreland
    added 2 commits that reference this issue on Dec 6, 2025

    pythongh-131885: Update unicodedata function signatures to use `/` (p…

    34aaa6c

    pythongh-131885: Document `*` for `code.InteractiveConsole` (python#1…

    bbbae69
  25. StanFromIreland
    added 3 commits that reference this issue on Aug 23, 2026

    gh-131885: Use real signatures in the `zlib` docs (#156179)

    d5e560e

    [3.14] gh-131885: Use real signatures in the `zlib` docs (GH-156179) (#…

    0514c59

    [3.13] gh-131885: Use real signatures in the `zlib` docs (GH-156179) (#…

    93fb365
  26. hugovk
    added a commit that references this issue on Aug 23, 2026

    [3.15] gh-131885: Use real signatures in the `zlib` docs (GH-156179) (#…

    4070837
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    • docs issues
      Status
      Todo
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.