Skip to content

Conversation

TaKO8Ki
Copy link
Contributor

@TaKO8Ki TaKO8Ki commented Sep 19, 2025

Summary

Fixes #20440

Fix B004 to skip invalid hasattr/getattr calls

  • Add argument validation for hasattr and getattr
  • Skip B004 rule when function calls have invalid argument patterns

Test Plan

Add comprehensive test cases for invalid argument patterns including unpacking to B004.py

Copy link
Contributor

github-actions bot commented Sep 19, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@dylwil3 dylwil3 self-requested a review September 19, 2025 18:05
Copy link
Collaborator

@dylwil3 dylwil3 left a comment

Choose a reason for hiding this comment

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

One nit and otherwise looks good, thank you!

@dylwil3 dylwil3 merged commit 43cda2d into astral-sh:main Sep 19, 2025
36 checks passed
@dylwil3 dylwil3 changed the title [ruff] Fix B004 to skip invalid hasattr/getattr calls [ruff] Fix B004 to skip invalid hasattr/getattr calls Sep 19, 2025
@dylwil3 dylwil3 added bug Something isn't working rule Implementing or modifying a lint rule labels Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

B004 false positives for invalid or obfuscated hasattr and getattr calls
2 participants