Fix crash on failed attribute inference - #11372
Open
rootsec1 wants to merge 1 commit into
Open
Conversation
DanielNoord
reviewed
Aug 31, 2026
Comment on lines
+1209
to
1212
| except (AttributeError, astroid.InferenceError): | ||
| continue | ||
| except astroid.DuplicateBasesError: | ||
| continue |
Collaborator
There was a problem hiding this comment.
Shall we just merge these then?
Contributor
|
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 6d7524f |
HDPark95
reviewed
Sep 1, 2026
HDPark95
left a comment
There was a problem hiding this comment.
Verified: crash reproduces on b44f86a, gone at 6d7524f; reverting only typecheck.py fails the new test (astroid-error), so it is load-bearing.
On continue: with several inferred owners, skipping only the failing one can create a message.
class Meta(type): pass
class A(metaclass=Meta): a = 1
class B: pass
OBJ = A if random.random() > 0.5 else B
print(OBJ.a) # clean without the line below
for Meta.a in _: pass # -> E1101: Class 'B' has no 'a' memberreturn, as has_dynamic_getattr above does for the same reason, drops it, keeps #11356 fixed, suite unchanged.
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.
Summary
InferenceErrorraised while resolving attributes forno-memberWhen attribute inference fails, the checker now skips that owner instead of aborting the lint run with
astroid-error. This follows the existing behavior for other unresolved attribute owners and avoids introducing a false positive from incomplete inference.Closes #11356
Tests
pytest -q tests/test_functional.py::test_functional[regression_11356] tests/checkers/unittest_typecheck.pypytest -q(2158 passed, 314 skipped, 5 xfailed)pre-commit run --files pylint/checkers/typecheck.py tests/functional/r/regression_03/regression_11356.py tests/functional/r/regression_03/regression_11356.rc doc/whatsnew/fragments/11356.bugfix