Repository navigation
Recommend is in the comparison-with-callable documentation - #11754
Open
thisisshivamtiwari wants to merge 1 commit into
Open
thisisshivamtiwari wants to merge 1 commit into
thisisshivamtiwari wants to merge 1 commit into
Conversation
Code that compares callables on purpose, for example to check which function was passed in, can use `is`: plain functions are only equal to themselves, and the message is not emitted for identity comparisons. Document this, along with the bound method caveat. Closes pylint-dev#7724 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type of Changes
Description
As suggested in #7724 (comment), this adds an "Additional details" section to the
comparison-with-callablemessage page. It covers code that compares callables on purpose, such as checking which function was passed in:isinstead of==. Plain functions are only equal to themselves, so the result is the same.isis not in the operators this check looks at, so the message is not emitted.obj.method is obj.methodisFalse, because each attribute access creates a new bound method, so the section suggests comparing__func__instead.I checked both claims locally.
callback is printis not reported andcallback == printis. For a bound methodcb = obj.greet,cb is obj.greetisFalseandcb.__func__ is Greeter.greetisTrue. The newdetails.rstpasses therstcheck,prettierandcodespellpre-commit hooks, and docutils renders it without warnings.doc/test_messages_documentation.py -k comparison-with-callablepasses. I did not build the full Sphinx docs locally.This is a documentation-only change, so I did not add a news fragment.
Closes #7724
🤖 Generated with Claude Code