github / github/codeql

assignment is unnessary under suppress()

未關閉
#7,638 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
false-positive not security Python
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

Maybe a bit of an edge case, but this code gives warning of unnessary assignments:
```
t = "<>"
with suppress(AttributeError):
# Set to type arg.
t = cls = get_args(self.__orig_class__)[0]
# If a class, set to the qualname.
t = cls.__qualname__
```

It should probably recognise that any code in a `suppress()` block may not actually run to completion.

https://lgtm.com/projects/g/aio-libs/aiohttp/snapshot/d6d827d7b26f2a54999f8a150ef230fe627aa435/files/aiohttp/helpers.py?sort=name&dir=ASC&mode=heatmap#x6cb8804f71fae0f2:1

貢獻指南

開啟貢獻指南

研究方向

首先在 aiohttp/helpers.py 中的範例上重現不必要的指派警告,重點關注 Python 的 suppress() 內容管理器周圍的指派分析行為。檢查相關的 CodeQL 查詢及其測試,然後驗證當執行可能無法完成時,suppress() 區塊內的指派不再被回報。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
security
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。