Skip to content

gh-72088: clarify inspect.ismethod and inspect.isfunction (and related) usage with class-level access#150013

Merged
encukou merged 13 commits into
python:mainfrom
stefmolin:update-inspect-ismethod-docs
May 18, 2026
Merged

gh-72088: clarify inspect.ismethod and inspect.isfunction (and related) usage with class-level access#150013
encukou merged 13 commits into
python:mainfrom
stefmolin:update-inspect-ismethod-docs

Conversation

@stefmolin
Copy link
Copy Markdown
Contributor

@stefmolin stefmolin commented May 18, 2026

Update inspect module docs to note the behavioral differences between inspecting instance methods accessed via the class versus via an instance when checking whether an object is a function or a method.

This is a continuation from the abandoned PR #146505. In addition to addressing the comments, I noticed the note wasn't correct in the case of class methods and static methods, so I modified the note to explicitly say it applied to instance methods and added a separate sentence for static methods.

Das-Chinmay and others added 3 commits March 26, 2026 21:42
…l access

Accessing a method through the class returns a plain function, not a
bound method, so ismethod() returns False in that case.  Add a note
and a cross-reference to the 'instance methods' section of the data
model reference to explain this.
…ass-level access

Update inspect docs to note the behavioral differences between inspecting
instance methods via the class versus via an instance  when checking whether
an object is a function or a method.
@stefmolin stefmolin marked this pull request as ready for review May 18, 2026 18:31
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 18, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32746553 | 📁 Comparing 7e0e9bf against main (806c997)

  🔍 Preview build  

2 files changed
± library/inspect.html
± whatsnew/changelog.html

@StanFromIreland
Copy link
Copy Markdown
Member

This is a continuation from the abandoned PR #146505.

Hmm, it is quite new, I'd suggest pinging the original author first, they may have just missed Petr's comment.

@encukou
Copy link
Copy Markdown
Member

encukou commented May 18, 2026

They also missed the bot comment; I think stale PRs are fair game.

Comment thread Doc/library/inspect.rst Outdated
Comment thread Doc/library/inspect.rst Outdated
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Sprint May 18, 2026
@encukou encukou merged commit 0aa59ce into python:main May 18, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs May 18, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Sprint May 18, 2026
@encukou encukou added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 18, 2026
@miss-islington-app
Copy link
Copy Markdown

Thanks @stefmolin for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link
Copy Markdown

Thanks @stefmolin for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link
Copy Markdown

Sorry, @stefmolin and @encukou, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 0aa59ce2d4f007a9d19740eb2f6230ed302096f7 3.13

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 18, 2026

GH-150033 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label May 18, 2026
@stefmolin stefmolin deleted the update-inspect-ismethod-docs branch May 18, 2026 22:48
encukou pushed a commit that referenced this pull request May 18, 2026
…(and related) usage with class-level access (GH-150013) (GH-150033)

(cherry picked from commit 0aa59ce)

Co-authored-by: Stefanie Molin <24376333+stefmolin@users.noreply.github.com>
Co-authored-by: CHINMAY <89741289+Das-Chinmay@users.noreply.github.com>
@encukou encukou removed the needs backport to 3.13 bugs and security fixes label May 18, 2026
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 skip news sprint

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants