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 — gh-161591: sync sphinx docs with actual signatures in the inspect module by skirpichev · Pull Request #161594 · python/cpython

Conversation

@skirpichev

@skirpichev skirpichev commented Nov 8, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Documented parameter names of some inspect functions don't match the implementation #161591

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@skirpichev
pythongh-161591: sync inspect.signature() docs with actual function s…
f3d7579
…ignature
@skirpichev skirpichev added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 8, 2026
@bedevere-app bedevere-app Bot added the awaiting review label Nov 8, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Nov 8, 2026
Documented parameter names of some inspect functions don't match the implementation #161591
Open
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Nov 8, 2026
@github-project-automation github-project-automation Bot added this to Docs PRs Nov 8, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Nov 8, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35747967 | 📁 Comparing 329b466 against main (f767423)

  🔍 Preview build  

8 files changed · ± 8 modified

± Modified

  • builtins/functions.html
  • builtins/stdtypes.html
  • faq/library.html
  • library/inspect.html
  • library/pdb.html
  • library/smtplib.html
  • library/tkinter.html
  • whatsnew/changelog.html
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev

skirpichev commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

I prefer sphinx's version of the argument name. But renaming would introduce API break (though hardly it's severe), not sure if it worth.

Kept changes minimal, per issue description. But in fact many singnatures in the inspect module are out of sync with the real code and/or just invalid. Examples:

.. function:: getmembers(object[, predicate])
   [...]
.. function:: getmembers_static(object[, predicate])
   [...]

I would prefer to fix all in one shot, in this pr, if reviewers support this.

CC @sobolevn

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Nov 8, 2026
View reviewed changes
Comment thread Doc/library/inspect.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Nov 8, 2026

Copy link
Copy Markdown
Member

I suggest you fix the docs properly even if naming is a bit.. wrong

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev
+1
d749ea3
@skirpichev
skirpichev force-pushed the inspect-sigs/161591 branch from 9458d81 to d749ea3 Compare November 8, 2026 10:33
@skirpichev

skirpichev commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

Ok, lets use obj...

But what about other signatures? Mentioned above could be fixed easily. Should I do it in this pr? Another one, formatargvalues() - probably must wait a better repr() for lambda, see #79037.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Nov 8, 2026
View reviewed changes
Comment thread Doc/library/inspect.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Nov 8, 2026
View reviewed changes

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmh. Now that you say it, the docs are more meaningful. Here's what I suggest:

  • in this PR, align the docs with actual signature
  • in a follow-up, let's decide whether to break the signatures or not; I would be favorable to. We can have a deprecation period where first arguments become deprecated when passed as keyword arguments. I made a similar change for hashlib where parameter string/data were used across multiple hash functions and I deprecated the 'string' parameter.

An alternative is to mark the first parmaeter as positional-only in the docs. It's a lie but... it would also hide the fact that it's an implementation detail and will forbid users to use named params.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@skirpichev @picnixz
Update Doc/library/inspect.rst
06c7183
Co-authored-by: Bénédikt Tran <[email protected]>
@skirpichev

skirpichev commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

in this PR, align the docs with actual signature

Ok, lets keep this as is.

in a follow-up, let's decide whether to break the signatures or not; I would be favorable to. We can have a deprecation period where first arguments become deprecated when passed as keyword arguments.

You meant:

  1. deprecate obj as positional or keyword
  2. make it positional-only, rename
  3. then allow it as keyword.

Sure, we can introduce breaking change that way, but IMO it's overkill. Hardly someone now uses signature(obj=foo) form versus positional argument.

An alternative is to mark the first parameter as positional-only in the docs.

Then next time someone else will point to inconsistency between docs and actual API.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Nov 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Ok, so let's do the doc update first. That is, sync every signature with existing code first. And in a follow-up, I suggest we just break the signatures (but for that we need an issue and maybe someone else that would be ok with that)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Nov 8, 2026

Copy link
Copy Markdown
Member

Btw, which signature is typeshed using?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev

skirpichev commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

Ok, so let's do the doc update first.

Done.

  1. formatargvalues() kept intact, as noted above
  2. getmodule() has private parameter, _filename: not added to sphinx docs, like we have for the Fraction constructor. IMO, signature() should have some option to omit private arguments per default.
  3. Signature constructor also has __validate_parameters__, probably it's private as well.
  4. getcallargs() has different names for vararg/kwarg parameters: kept intact as there is not API difference.
  5. getattr_static() uses old-style sentinel for default

Btw, which signature is typeshed using?

obj. It looks, they follow to sources.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev
+1
569844f
@skirpichev skirpichev changed the title gh-161591: sync inspect.signature() docs with actual function signature gh-161591: sync sphinx docs with actual signatures in the inspect module Nov 9, 2026
vadmium
vadmium reviewed Nov 9, 2026
View reviewed changes
Comment thread Doc/library/inspect.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev @vadmium
Update Doc/library/inspect.rst
329b466
Co-authored-by: Martin Panter <[email protected]>
@skirpichev
skirpichev requested a review from vadmium November 9, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@picnixz picnixz picnixz left review comments
@vadmium vadmium Awaiting requested review from vadmium

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review docs Documentation in the Doc dir needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes skip news

Projects

Docs PRs
Status: Todo

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@skirpichev @picnixz @vadmium
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.