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
Copy link
Contributor

github-actions bot commented Nov 1, 2025

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

This comment was generated for commit 484e910

@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 95.97%. Comparing base (f8f6ccd) to head (484e910).

Additional details and impacted files

Impacted file tree graph

@@ Coverage Diff @@ ## main #10715 +/- ## ======================================= Coverage 95.97% 95.97% ======================================= Files 176 176 Lines 19537 19537 ======================================= Hits 18750 18750 Misses 787 787 
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
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants