fix: check hasattr(qname) before calling in is_abstract#3141
Open
muhamedfazalps wants to merge 3 commits into
Open
fix: check hasattr(qname) before calling in is_abstract#3141muhamedfazalps wants to merge 3 commits into
muhamedfazalps wants to merge 3 commits into
Conversation
When prefer_stubs is True, the code now checks for .pyi files first before returning the original file (e.g., .pyc). This ensures .pyi stubs take precedence over compiled bytecode files, fixing a regression where .pyi files were no longer recognized. Fixes pylint-dev#3087
Merging this PR will not alter performance
Comparing Footnotes
|
The is_abstract method called inferred.qname() without checking if the object has a qname() method. When a TypeVar is used as a decorator, inferred is a TypeVar object which doesn't have qname(), causing an AttributeError. This fix adds hasattr(inferred, 'qname') check before calling qname(). Fixes pylint-dev#3086
1536e93 to
4dd39b2
Compare
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3141 +/- ##
==========================================
- Coverage 93.62% 93.59% -0.04%
==========================================
Files 92 92
Lines 11383 11389 +6
==========================================
+ Hits 10657 10659 +2
- Misses 726 730 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
DanielNoord
reviewed
Jul 12, 2026
DanielNoord
left a comment
Collaborator
There was a problem hiding this comment.
Please fix by implementing qname on TypeVar
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.
Fixes #3086
The
is_abstractmethod calledinferred.qname()without checking if the object has aqname()method. When aTypeVaris used as a decorator,inferredis aTypeVarobject which doesn't haveqname(), causing anAttributeError.This fix adds
hasattr(inferred, 'qname')check before callingqname().---\n\nbuymeacoffee.com/muhamedfazalps