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

UP032 became less useful in v0.3.1 #10259

Closed
ThiefMaster opened this issue Mar 6, 2024 · 4 comments
Closed

UP032 became less useful in v0.3.1 #10259

ThiefMaster opened this issue Mar 6, 2024 · 4 comments
Assignees

Comments

@ThiefMaster
Copy link
Contributor

The whole change in that rule to trigger even when it causes a longer line feels kind of annoying and the fact that there's no autofix doesn't make it better: Fixing it requires manual work anyway, but I'd rather start from a too-long line which I just need to wrap somehow, than having to do the whole fix myself. --> Couldn't it simply be an unsafe autofix in such cases?

Some example where just using f-string isn't great / very readable:

return '{} - {}'.format(
    format_skeleton(start_dt, day_month, timezone=tzinfo),
    format_skeleton(end_dt, day_month, timezone=tzinfo)
)

(of course this one can easily be refactored to separate statements and then a nicely compact f-string)

        db.CheckConstraint('(input_type IS NULL) = (type NOT IN ({t.field}, {t.field_pd}))'
                           .format(t=RegistrationFormItemType),

In this case an f-string do not provide the same level of functionality. And this happens to be part of an sqlalchemy __table_args__ class attribute, so moving the assignment to a separate statement would clutter the class scope (or require an explicit del t afterwards).

@mmerickel
Copy link
Contributor

Ran into this too with a bunch of tedious fixes. An unsafe autofix would be great to just have to deal with the line length afterward. Running the pyupgrade tool directly doesn't trigger on these lines either so ruff is being more strict here which is fine but an autofix would just be really helpful.

@charliermarsh
Copy link
Member

I've enabled the autofix for these new violations here: #10263.

@charliermarsh
Copy link
Member

Part of the problem is we don't really have a mechanism for gating by line length -- it's not really the intent of fix safety, which is intended to capture changes in the semantics and meaning of the code. So in that PR, I've made it a safe fix regardless. There's some discussion on the broader issue here, if anyone has opinions: #8106.

@charliermarsh
Copy link
Member

Merged!

@charliermarsh charliermarsh self-assigned this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants