Skip to content

helpers: simplify Uninferable type error message#3010

Merged
DanielNoord merged 1 commit intopylint-dev:mainfrom
SergioChan:fix/issue-2760-uninferable-error-message
Mar 21, 2026
Merged

helpers: simplify Uninferable type error message#3010
DanielNoord merged 1 commit intopylint-dev:mainfrom
SergioChan:fix/issue-2760-uninferable-error-message

Conversation

@SergioChan
Copy link
Contributor

Type of Changes

Type
🔨 Refactoring

Description

Closes #2760

This simplifies the AstroidTypeError branch in _object_type_is_subclass.

When klass is Uninferable, we already know its exact type from the guard:

if isinstance(klass, util.UninferableBase):

So the error message no longer needs runtime interpolation via type(klass).
The message is now emitted as a static literal while preserving the same text output.

Validation

  • python -m pytest tests/brain/test_brain.py -k "isinstance or issubclass"
    • 35 passed, 105 deselected

@SergioChan SergioChan force-pushed the fix/issue-2760-uninferable-error-message branch from 38ad36d to 0d6ef31 Compare March 21, 2026 05:27
@SergioChan
Copy link
Contributor Author

Rebased this PR branch onto current main and force-pushed to resolve the branch divergence.

What changed:

  • Reapplied the existing issue fix commit on top of latest main.
  • No functional changes beyond the same targeted error-message behavior.

Validation run:

  • python -m pytest tests/test_helpers.py -k Uninferable -q (3 passed)

@DanielNoord DanielNoord enabled auto-merge (rebase) March 21, 2026 17:32
@codecov
Copy link

codecov bot commented Mar 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.27%. Comparing base (b4824be) to head (0d6ef31).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3010   +/-   ##
=======================================
  Coverage   93.27%   93.27%           
=======================================
  Files          92       92           
  Lines       11350    11350           
=======================================
  Hits        10587    10587           
  Misses        763      763           
Flag Coverage Δ
linux 93.14% <ø> (ø)
pypy 93.27% <ø> (ø)
windows 93.25% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
astroid/helpers.py 94.93% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanielNoord DanielNoord merged commit c5d140d into pylint-dev:main Mar 21, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use of klass unnecessary as we always know the exact type (Uninferable)

2 participants