Skip to content

RUF052 Fix Breaks Overload Definitions #14799

@oguzhanmeteozturk

Description

@oguzhanmeteozturk

The automatic fix for RUF052 introduces inconsistent parameter renaming in overload definitions. Specifically, if a parameter name is prefixed with an underscore (e.g., _param), the fixer renames it inconsistently across overloads and the main function. This leads to invalid overload definitions, as parameter names must match exactly between overloads and the implementation.

@overload
def func(
    tp: str, value: object, /, *, strict: bool = True, eval: bool = True, _param: str = "func"
) -> bool: ...

@overload
def func(
    tp: type[_T], value: object, /, *, strict: bool = True, eval: bool = True, _param: str = "func"
) -> _T | None: ...

def func(
    tp: str | type[_T] | object, value: object,  /, *, strict: bool = True, eval: bool = True, param: str = "func" 
) -> _T | object | None: ...

I am not fully up to date on the process or discussions around RUF052, but given the potential for these changes to render code invalid, I wonder why wasn’t this fix categorized as an unsafe fix requiring explicit user consent in the first place?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixesRelated to suggested fixes for violationspreviewRelated to preview mode features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions