Skip to content

Conversation

@zenlyj
Copy link
Contributor

@zenlyj zenlyj commented Nov 1, 2025

Type of Changes

Type
βœ“ πŸ› Bug fix
✨ New feature
πŸ”¨ Refactoring
πŸ“œ Docs

Description

Add a runtime type guard before accessing qname() on inferred called function for both prefer-typing-namedtuple and consider-math-not-float checks.

Closes #10708

@zenlyj zenlyj requested a review from cdce8p as a code owner November 1, 2025 14:33
@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 95.98%. Comparing base (133681e) to head (d9988c0).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10715   +/-   ##
=======================================
  Coverage   95.98%   95.98%           
=======================================
  Files         176      176           
  Lines       19540    19540           
=======================================
  Hits        18755    18755           
  Misses        785      785           
Files with missing lines Coverage Ξ”
pylint/extensions/code_style.py 100.00% <100.00%> (ΓΈ)
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zenlyj zenlyj changed the title Fix crash for prefer-typing-namedtuple and consider-math-not-float when a slice object is called. Fix crash when a slice object is called Nov 1, 2025
DanielNoord
DanielNoord previously approved these changes Nov 3, 2025
@Pierre-Sassoulas Pierre-Sassoulas added this to the 4.0.3 milestone Nov 3, 2025
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.

I think it's okay to pre-filter, maybe we don't have to filter anymore after that ? (It's not the first crash that the fuzzing caught by using slice instead of functiondev/classdef, maybe we can anticipate other instances of that without waiting for "random luck"). Maybe by creating a safe_infer_call function ?

Comment on lines 116 to 117
if not called:
return
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if not called:
return
if not (called and isinstance(called, (nodes.FunctionDef, nodes.ClassDef))):
return

Copy link
Contributor Author

@zenlyj zenlyj Nov 8, 2025

Choose a reason for hiding this comment

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

Good point with the safe_infer_call, it seems that there are a number of usages where we infer call and access qname. I will put out a separate PR for that change.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

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.

Great !

@Pierre-Sassoulas Pierre-Sassoulas enabled auto-merge (squash) November 9, 2025 18:51
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2025

πŸ€– According to the primer, this change has no effect on the checked open source code. πŸ€–πŸŽ‰

This comment was generated for commit d9988c0

@Pierre-Sassoulas Pierre-Sassoulas merged commit 0a2cb33 into pylint-dev:main Nov 9, 2025
44 checks passed
pylint-backport bot pushed a commit that referenced this pull request Nov 9, 2025
Co-authored-by: Pierre Sassoulas <[email protected]>
(cherry picked from commit 0a2cb33)
Pierre-Sassoulas added a commit that referenced this pull request Nov 9, 2025
#10728)

Fix crash when a `slice` object is called (#10715)


(cherry picked from commit 0a2cb33)

Co-authored-by: Zen Lee <[email protected]>
Co-authored-by: Pierre Sassoulas <[email protected]>
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.

AttributeError: 'Slice' object has no attribute 'qname' in code_style checker

3 participants