Skip to content

Conversation

@emmanuel-ferdman
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

This PR fixes an IndexError crash when parsing _CallableType() or _TupleType() calls with no arguments. The _looks_like_special_alias() predicate was attempting to access node.args[0] without first checking if the arguments list was empty. The fix adds a simple guard condition and node.args using short-circuit evaluation to ensure the list is non-empty before indexing.

Example:

_CallableType()
_TupleType()

Current Output:

IndexError: list index out of range
File "astroid/brain/brain_typing.py", line 368, in _looks_like_special_alias
      and isinstance(node.args[0], Attribute)
                     ~~~~~~~~~^^^

Closes #2772

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@codecov
Copy link

codecov bot commented Oct 1, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 93.37%. Comparing base (a14cc3c) to head (16f0e8b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2844   +/-   ##
=======================================
  Coverage   93.37%   93.37%           
=======================================
  Files          92       92           
  Lines       11148    11148           
=======================================
  Hits        10409    10409           
  Misses        739      739           
Flag Coverage Ξ”
linux 93.23% <100.00%> (ΓΈ)
pypy 93.37% <100.00%> (ΓΈ)
windows 93.35% <100.00%> (ΓΈ)

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

Files with missing lines Coverage Ξ”
astroid/brain/brain_typing.py 88.81% <100.00%> (ΓΈ)
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘Œ

@Pierre-Sassoulas Pierre-Sassoulas merged commit f25ef82 into pylint-dev:main Oct 2, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexError when _CallableType() has no arguments

2 participants