Re-code flake8-trio and flake8-async rules to match upstream#10416
Re-code flake8-trio and flake8-async rules to match upstream#10416MichaReiser merged 22 commits intoastral-sh:ruff-0.5from
Conversation
|
This is mostly done, except for the previous ASYNC101 and ASYNC102 which don't exactly match any the of the new ASYNC rules. The closest matches are ASYNC220 and ASYNC222, but the behaviors don't match exactly. Part of the problem is that the previous rules should be split into multiple rules (this is easy). The other problem which I'm not sure how to resolve is that it doesn't seem like any of the new ASYNC rules check for |
|
|
Ok so I modified the implementation of ASYNC220 and ASYNC222, as well as added ASYNC221 so that the three rules would match the behavior of flake8-async. For now I added a check for time.sleep as part of ASYNC222. |
|
Oh, I'd missed that we don't check for time.sleep anymore. It's a bad match for ASYNC222, as the recommended replacement is using |
66f14b4 to
bcb1947
Compare
|
Ok I moved the time.sleep check to a newly created ASYNC251 |
|
We've just released ASYNC251 upstream, so this is back to matching the merged flake8-async plugin. |
|
Note that we'll need to add "redirects" for all of these rules, see rule_redirects.rs. See #9756 for example. We may be able to make use of #9691 as well, not sure yet. |
|
Ok I added redirects for the old TRIO rules. But as mentioned the old ASYNC rules don't directly correspond to new ASYNC rules. |
|
I've got some comments on the human-friendly rule names you have, and it might be good if we synced them to ease transition between flake8-async and ruff. See python-trio/flake8-async#248 (comment) (I'm sorry we're moving so quickly as of late 😁) |
|
This PR has some merge conflicts now, anything I can do to help? I'm motivated to add (the new) ASYNC101 to Ruff because of the problems mentioned in the draft PEP 789. |
|
The main issue is that it's going to be a breaking change for users (e.g., |
|
@zanieb - let's include this in v0.5.0 since it's starting to cause problems. |
|
@augustelalande -- I'm happy to take responsibility for resolving any conflicts. |
|
@charliermarsh I'll do it now. I'm also gonna update the rules with the new names from python-trio/flake8-async#248 (comment) |
|
Nevermind the last part. Updating all the rule names is a significant effort so should be a separate PR. |
11b9beb to
bf8ec83
Compare
|
Okay, I'm done with the rebase and I very much hope I didn't mess anything up. I now need to get a better understanding of the change itself to be able to review it :) |
|
I'm trying to get my head around over all the changes and are having a hard time. What's unclear to me is:
|
|
From the chanegelog: |
|
Okay, I think I now have a good overview of what has changed. I plan on reviewing this PR tomorrow (and hopefully merge). I don't think there's anything we can do about mapping the old Trio to ASYNC
ASYNC rule changes
|
20052db to
d3d93d7
Compare
|
I manually tested the redirection rules and it all looks good. Let's merge this. |
|
I think one nice follow up after the release would be to rename the rules to match the upstream names. |
Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Micha Reiser <micha@reiser.io>
Summary
Re-code flake8-trio and flake8-async rules to match upstream. Resolves #10303.
TRIOrulesTRIOhas been renamed toASYNC1TRIO100->ASYNC100TRIO105->ASYNC105TRIO109->ASYNC109TRIO110->ASYNC110TRIO115->ASYNC115ASYNCrulesASYNC116unchangedASYNC100..ASYNC102has been renamed toASYNC2ASYNC100moved toASYNC210,ASYNC101was split intoASYNC220,ASYNC221,ASYNC222,ASYNC230, andASYNC251ASYNC102was merged intoASYNC220andASYNC221Behavior changes
ASYNC210(previouslyASYNC100): Now detectsurllib3.requestcallsASYNC230: Now also detects calls toio.open,io.open_codeTest Plan