ASYNC912: Warn on unnecessary checkpoints added to avoid ASYNC910/911
@jakkdl 已经在做这个了。
开始于 2022年12月1日。
评估
这个 Issue 还没有评估数据。
描述
I've noticed a few places where await trio.sleep(0) is added in places that don't actually need a checkpoint, and so I've thought up a two-part plan to mitigate cargo-cult copy-paste coding.
- Instead of
await trio.sleep(0), suggestawait trio.lowlevel.checkpoint(). It's an identical runtime effect, but the name is much more suggestive of what's actually going on: "we need a checkpoint here for some low-level reason" ✅ - Refactoring the increasingly-large plugin file as suggested below.
- In each async function, for each
await trio.lowlevel.checkpoint(), check if there would be no 107/108 warnings emitted if that checkpoint was removed (in addition to any already-suggested-removals, of course).
I initially marked this as an "idea" issue rather than for implementation because while I'm fairly confident (1) is a good plan, (2) seems a little harder to implement. It's also triggering my "this feels pretty tedious" detector, but building a libCST-based autofixer also seems like a little too much duplication of effort, right? Even if we could autofix 105, 107, 108, 112, and 113; and hook it in to shed --refactor... tempting but probably not worth it 😕
Thoughts?
- 主要语言
- Python
- 星标
- 26
- 派生
- 10
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-trio/flake8-async 的其他 Issue
-
rule improvement
难度 2/5 1-3 小时 新手友好度 68/100
python-trio/flake8-async#457 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 68/100
python-trio/flake8-async#475 · 1 条评论 ·
-
new rule
难度 3/5 1-2 天 新手友好度 55/100
python-trio/flake8-async#454 · 1 条评论 ·
-
rule improvement
难度 3/5 1-2 天 新手友好度 62/100
python-trio/flake8-async#447 · 5 条评论 ·
-
good first issue
难度 5/5 一周以上 新手友好度 15/100
python-trio/flake8-async#396 · 1 条评论 ·
查看 python-trio/flake8-async 的全部 Issue
相似的 Issue
-
bug confirmed issue
难度 2/5 1-3 小时 新手友好度 75/100
open-webui/open-webui#30750 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
-
good first issue
难度 1/5 1 小时以内 新手友好度 90/100