New asyncio rule: directly passing coroutine to `gather`, `shield`, `wait_for`, `wait`, or `as_completed`
まだ誰も着手していません。
評価
調査の方向性
まず、既存の asyncio ルール実装とそのテストを見つけます。gather、shield、wait_for、wait、as_completed に対する直接の coroutine 引数の処理を追跡し、その後、Python の各バージョンで期待される動作を確認します。Python 3.11 以降の wait も含めます。新しいルールが説明されている直接呼び出しを検出し、false positive に関するトレードオフがテストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Tasks without saved reference can be garbage collected, and several functions in asyncio automatically converts coroutines into tasks - which means it's ~impossible to save a strong reference to those tasks. See e.g. https://docs.python.org/3/library/asyncio-task.html#asyncio.shield
The rule implementation would be fairly straightforward, just check for calls in the parameter list: asyncio.shield(anything()). This will give false alarms if anything is not a coroutine, but instead a sync function that creates a task, saves it globally, and returns it, but I suspect that's a minority of cases. We could save the names of any sync funcs to reduce the false alarm rate, but that wouldn't work when the functions are imported from other files.
We could also use type-checking to catch
a = my_coro()
asyncio.wait_for(a)
On py311+ asyncio.wait errors if directly passed coroutines.
There appears to be movement in making the event loop save strong references, but that'll probably only affect py3.14/py3.15 or later https://github.com/python/cpython/pull/121264
- 主要言語
- Python
- スター
- 26
- フォーク
- 10
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-trio/flake8-async のほかの issue
-
rule improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
python-trio/flake8-async#457 · リアクション 1 件 ·
-
Extend ASYNC401 to other forms対応中かも @anshurajbisoyi98-ctrl が 3 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
python-trio/flake8-async#475 · コメント 1 件 · リアクション 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 件 ·
-
New rule: `ASYNC233` for blocking `pathlib` methods対応中かも @paranoa233 が 91 日前に担当しました。 オープンgood first issue
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
python-trio/flake8-async#396 · コメント 1 件 ·
python-trio/flake8-async の issue をすべて見る
似ている issue
-
needs-human needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
gke-labs/kube-agents#2400 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Device Details tables: FS/SF columns contradict each other (nfet_01v8 Vt row, pfet_01v8 Idsat row)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
google/skywater-pdk#450 ·
-
Drained trajectory arrays are overwritten when the sequence buffer is reused対応中かも @sylvesterkaczmarek が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google-deepmind/bsuite#56 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
LearningCircuit/local-deep-research#7206 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
chingu-voyages/V62-tier3-team-33#285 ·
メンテナーはふだん 1 日以内に返信