Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUF052 Fix Breaks Overload Definitions #14799

Closed
oguzhanmeteozturk opened this issue Dec 5, 2024 · 2 comments · Fixed by #14818
Closed

RUF052 Fix Breaks Overload Definitions #14799

oguzhanmeteozturk opened this issue Dec 5, 2024 · 2 comments · Fixed by #14818
Labels
bug Something isn't working fixes Related to suggested fixes for violations preview Related to preview mode features

Comments

@oguzhanmeteozturk
Copy link

oguzhanmeteozturk commented Dec 5, 2024

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?

@AlexWaygood AlexWaygood added bug Something isn't working fixes Related to suggested fixes for violations preview Related to preview mode features labels Dec 5, 2024
@MichaReiser
Copy link
Member

Thanks. Marking the fix as unsafe is a good first step if the binding belongs to a function parameter.

@MichaReiser
Copy link
Member

Related to #14790 and #14796

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations preview Related to preview mode features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants