diff --git a/.github/scripts/gitutils.py b/.github/scripts/gitutils.py index 9b20c7aed001a9..d057f3e45a61fe 100644 --- a/.github/scripts/gitutils.py +++ b/.github/scripts/gitutils.py @@ -38,7 +38,7 @@ def fuzzy_list_to_dict(items: List[Tuple[str, str]]) -> Dict[str, List[str]]: """ Converts list to dict preserving elements with duplicate keys """ - rc: Dict[str, List[str]] = defaultdict(lambda: []) + rc: Dict[str, List[str]] = defaultdict(list) for key, val in items: rc[key].append(val) return dict(rc) diff --git a/pyproject.toml b/pyproject.toml index 2b16f472f612f9..220986d1160ea7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,8 @@ select = [ "UP", "PERF", "PGH004", + "PIE807", + "PIE810", "PLE", "TRY302", ] diff --git a/torch/_export/db/case.py b/torch/_export/db/case.py index cea04fe4189f7a..7ba0b657035f30 100644 --- a/torch/_export/db/case.py +++ b/torch/_export/db/case.py @@ -78,7 +78,7 @@ class ExportCase: # Tags associated with the use case. (e.g dynamic-shape, escape-hatch) tags: Set[str] = field(default_factory=lambda: set()) support_level: SupportLevel = SupportLevel.SUPPORTED - constraints: List[Constraint] = field(default_factory=lambda: []) + constraints: List[Constraint] = field(default_factory=list) def __post_init__(self): check_inputs_type(self.example_inputs) diff --git a/torchgen/gen.py b/torchgen/gen.py index 9766c8af5bc0f5..19fa667f33e20e 100644 --- a/torchgen/gen.py +++ b/torchgen/gen.py @@ -1846,13 +1846,13 @@ def gen_per_operator_headers( ) -> None: # For CMake builds, split operator declarations into separate headers in # the ATen/ops folder to split up header dependencies - functions_by_root_name: Dict[str, List[NativeFunction]] = defaultdict(lambda: []) + functions_by_root_name: Dict[str, List[NativeFunction]] = defaultdict(list) for fn in native_functions: functions_by_root_name[fn.root_name].append(fn) grouped_functions_by_root_name: Dict[ str, List[Union[NativeFunction, NativeFunctionsGroup]] - ] = defaultdict(lambda: []) + ] = defaultdict(list) for group in grouped_native_functions: name = group.root_name grouped_functions_by_root_name[name].append(group)