Skip to content

B004 fix deletes comments #18741

@MeGaGiGaGon

Description

@MeGaGiGaGon

Summary

B004 deletes comments inside the hasattr call, so should be marked unsafe in that case playground

PS ~\Desktop\New_folder>Set-Content .\issue.py @"
>> hasattr(
>> # 1
>> obj, # 2
>> # 3
>> "__call__" # 4
>> # 5
>> )
>> "@
PS ~\Desktop\New_folder>uvx ruff check --select B --fix issue.py
Found 1 error (1 fixed, 0 remaining).
PS ~\Desktop\New_folder>Get-Content issue.py
callable(obj)

Version

ruff 0.12.0 (87f0feb 2025-06-17) + playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixesRelated to suggested fixes for violationshelp wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions