[Easy][BE]: Enable RUF008 and RUF016 checks (#116195)

Enables a few more static linting checks for mutable defaults in dataclasses and for detecting a common type error.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/116195
Approved by: https://github.com/malfet
This commit is contained in:
Aaron Gokaslan 2023-12-20 21:16:45 +00:00 committed by PyTorch MergeBot
parent bc0d8649a4
commit 6e2c9be501
2 changed files with 4 additions and 2 deletions

View File

@ -106,7 +106,9 @@ select = [
"PT025",
"PT026",
"PYI",
"RUF008", # mutable dataclass default
"RUF015", # access first ele in constant time
"RUF016", # type error non-integer index
"RUF017",
"TRY200",
"TRY302",

View File

@ -1,6 +1,6 @@
import functools
from contextlib import contextmanager
from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Set, Tuple
import torch
@ -27,7 +27,7 @@ class TracingConfig:
in :meth:`~torch.fx.Tracer.trace`.
"""
tracer: torch.fx.Tracer = torch.fx.Tracer()
tracer: torch.fx.Tracer = field(default_factory=torch.fx.Tracer)
concrete_args: Optional[Dict[str, Any]] = None