PyCQA/flake8-bugbear

B006: Case where mutable default arguments are not detected

オープン

#253 opened on 2022/04/10

 (5 件のコメント) (0 件のリアクション) (0 人の担当者)Python (116 件のフォーク)github user discovery
bughelp wanted

Repository metrics

Stars
 (1,116 個のスター)
PR merge metrics
 (平均マージ 4h 17m) (30d で 3 merged PRs)

説明

I realized that when using Python built-in dataclasses, the following scenario is not detected:

from dataclasses import dataclass

@dataclass
class MyClass:
    val = []  # Mutable data structure

Given the presence of the dataclass decorator, the signature of the __init__ method for MyClass is the following one:

def __init__(self, val = []):

I have seen that the rule B006 is supposed to detect issues where mutable data structures are used in a function signature. This is a slightly different scenario but with the same output if this effect is not intended. I could not find any related issue. Was this issue reported before?

コントリビューターガイド