Skip to content

Raise a type error in object_len for a __len__ that cannot be called - #3426

Open
Pierre-Sassoulas wants to merge 2 commits into
pylint-dev:mainfrom
Pierre-Sassoulas:fix/object-len-uncallable-dunder-len
Open

Pierre-Sassoulas wants to merge 2 commits into
pylint-dev:mainfrom
Pierre-Sassoulas:fix/object-len-uncallable-dunder-len

Conversation

@Pierre-Sassoulas

Copy link
Copy Markdown
Member

Type of Changes

Type
✓ 🔨 Refactoring

Description

A __len__ class attribute bound to something that is not callable,
such as a module, made len() inference crash with an AttributeError
because infer_call_result was called on it unconditionally.

A ``__len__`` class attribute bound to something that is not callable,
such as a module, made ``len()`` inference crash with an AttributeError
because ``infer_call_result`` was called on it unconditionally.
@Pierre-Sassoulas Pierre-Sassoulas added this to the 4.4.0 milestone Oct 22, 2026
@codspeed

codspeed Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 3 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing Pierre-Sassoulas:fix/object-len-uncallable-dunder-len (389f660) with main (b5e78cd)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.15%. Comparing base (b5e78cd) to head (389f660).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3426   +/-   ##
=======================================
  Coverage   91.15%   91.15%           
=======================================
  Files          93       93           
  Lines       11800    11802    +2     
  Branches     1938     1939    +1     
=======================================
+ Hits        10756    10758    +2     
  Misses        735      735           
  Partials      309      309           
Flag Coverage Δ
linux 90.83% <100.00%> (+<0.01%) ⬆️
pypy 91.15% <100.00%> (+<0.01%) ⬆️
windows 90.99% <100.00%> (+<0.01%) ⬆️

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

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant