Dangerous default value [] as argument
还没有人认领这个 Issue。
评估
调研方向
从 PR #456 开始,在 Python 代码库中搜索默认值为 [] 的函数参数。使用此 issue 中的 Test 示例来理解共享状态 bug,并确认哪些出现位置属于范围之内。当预期的可变列表默认值使用安全初始化且现有测试套件通过时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
This issue came up in PR #456.
I wasn't really aware of this issue ... thought it would be just coding style. We should open an issue and fix it in a new PR, maybe like this:
def __init__(self, some_list=None):
self.some_list = some_list or []
Codacy is giving me "Dangerous default value [] as argument" but this happens a lot elsewhere. I agree this should be changed, but maybe not in this PR...
I think this should really be changed, because this can lead to very hard to find bugs:
class Test: def __init__(self, some_list=[]): self.some_list = some_list t1 = Test() t2 = Test() t2.some_list.append(1) print(t1.some_list) # prints [1]
Originally posted by @cehbrecht in https://github.com/geopython/pywps/pull/456#issuecomment-471551513
- 主要语言
- Python
- 星标
- 186
- 派生
- 116
- 平均合并
- 11 天 20 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
geopython/pywps 的其他 Issue
-
ReadTheDocs OAuth App Installation可能重新可做 @tomkralidis 于 72 天前认领,目前没有进行中的 PR。 未关闭documentation
-
Modernizing the packaging of the library可能重新可做 @Zeitsperre 于 285 天前认领,目前没有进行中的 PR。 未关闭documentation enhancement packaging
-
难度 2/5 1-3 小时 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 35/100
相似的 Issue
-
repo-audit
难度 2/5 1-3 小时 新手友好度 75/100
scverse/repo-health#20 ·
维护者通常 1 天内回复
-
/context/prime scope override double-prefixes an entity-ref project and drops its scoped memories未关闭
难度 2/5 1-3 小时 新手友好度 85/100
phasespace-labs/palinode#232 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
collective/icalendar#1858 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
langflow-ai/langflow#15496 ·
维护者通常 1 天内回复