diff --git a/.flake8 b/.flake8 index b5a61410d3e..ad26691425c 100644 --- a/.flake8 +++ b/.flake8 @@ -14,7 +14,7 @@ ignore = # to line this up with executable bit EXE001, # these ignores are from flake8-bugbear; please fix! - B007,B008,B017,B019,B020,B023,B024,B026,B027,B028,B903,B904,B905,B906,B907 + B007,B008,B017,B019,B020,B023,B024,B026,B028,B903,B904,B905,B906,B907 # these ignores are from flake8-comprehensions; please fix! C407, # these ignores are from flake8-logging-format; please fix! diff --git a/.lintrunner.toml b/.lintrunner.toml index 05a089a834d..aa4104c214d 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -999,6 +999,6 @@ init_command = [ 'python3', 'tools/linter/adapters/pip_init.py', '--dry-run={{DRYRUN}}', - 'ruff==0.0.262', + 'ruff==0.0.265', ] is_formatter = true diff --git a/caffe2/python/modeling/net_modifier.py b/caffe2/python/modeling/net_modifier.py index c0545fad08f..55f47f8fbac 100644 --- a/caffe2/python/modeling/net_modifier.py +++ b/caffe2/python/modeling/net_modifier.py @@ -17,9 +17,6 @@ class NetModifier(metaclass=abc.ABCMeta): modifier(net) """ - def __init__(self): - pass - @abc.abstractmethod def modify_net(self, net, init_net=None, grad_map=None, blob_to_device=None): pass diff --git a/pyproject.toml b/pyproject.toml index 9767221767a..75237c629bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ ignore = [ "B019", "B020", "B023", "B024", "B026", "B028", # No explicit `stacklevel` keyword argument found - "B027", "B904", "B905", + "B904", "B905", "E402", "C408", # C408 ignored because we like the dict keyword argument syntax "E501", # E501 is not flexible enough, we're using B950 instead diff --git a/test/dynamo/test_misc.py b/test/dynamo/test_misc.py index 4b28e52baba..a26010434ef 100644 --- a/test/dynamo/test_misc.py +++ b/test/dynamo/test_misc.py @@ -3521,7 +3521,7 @@ def fn(): def test_user_function_variable_supports_type_abcmeta_argument(self): class Foo(metaclass=abc.ABCMeta): @abc.abstractclassmethod - def read(self): + def read(self): # noqa: B027 pass class Bar(Foo): diff --git a/torch/ao/quantization/fx/fuse_handler.py b/torch/ao/quantization/fx/fuse_handler.py index 2706f96fef3..718cc561bfa 100644 --- a/torch/ao/quantization/fx/fuse_handler.py +++ b/torch/ao/quantization/fx/fuse_handler.py @@ -23,6 +23,7 @@ __all__ = [ class FuseHandler(ABC): """ Base handler class for the fusion patterns """ + @abstractmethod def __init__(self, node: Node): pass diff --git a/torch/distributed/checkpoint/_fsspec_filesystem.py b/torch/distributed/checkpoint/_fsspec_filesystem.py index 904f4bb2136..5726d4aab63 100644 --- a/torch/distributed/checkpoint/_fsspec_filesystem.py +++ b/torch/distributed/checkpoint/_fsspec_filesystem.py @@ -78,6 +78,7 @@ class _TensorLoader(ABC): def add(self, size: int, obj: object): pass + @abstractmethod def start_loading(self): pass diff --git a/torch/distributed/checkpoint/filesystem.py b/torch/distributed/checkpoint/filesystem.py index 9074b16e935..61571d8602b 100644 --- a/torch/distributed/checkpoint/filesystem.py +++ b/torch/distributed/checkpoint/filesystem.py @@ -84,6 +84,7 @@ class _TensorLoader(ABC): def add(self, size, obj): pass + @abstractmethod def start_loading(self): pass diff --git a/torch/distributed/elastic/rendezvous/api.py b/torch/distributed/elastic/rendezvous/api.py index 73ba2ad7c34..2b59be4b5eb 100644 --- a/torch/distributed/elastic/rendezvous/api.py +++ b/torch/distributed/elastic/rendezvous/api.py @@ -105,6 +105,7 @@ class RendezvousHandler(ABC): allow nodes to join the correct distributed application. """ + @abstractmethod def shutdown(self) -> bool: """Closes all resources that were open for the rendezvous. diff --git a/torch/distributed/fsdp/wrap.py b/torch/distributed/fsdp/wrap.py index 0fbaee2e612..febe2e39425 100644 --- a/torch/distributed/fsdp/wrap.py +++ b/torch/distributed/fsdp/wrap.py @@ -39,8 +39,6 @@ class _FSDPPolicy(ABC): # The motivation for this abstract base class is to hide the interface # expected by `_recursive_wrap()` from users (i.e. the `recurse` argument). - def __init__(self): - ... @property @abstractmethod diff --git a/torch/fx/passes/infra/pass_base.py b/torch/fx/passes/infra/pass_base.py index cb194a56c68..dd699ea86cd 100644 --- a/torch/fx/passes/infra/pass_base.py +++ b/torch/fx/passes/infra/pass_base.py @@ -31,9 +31,6 @@ class PassBase(abc.ABC): the PassManager's `passes` attribute. """ - def __init__(self) -> None: - pass - def __call__(self, graph_module: GraphModule) -> Optional[PassResult]: """ Runs the precondition check, the pass itself, and the postcondition check. @@ -55,7 +52,7 @@ class PassBase(abc.ABC): """ pass - def requires(self, graph_module: GraphModule) -> None: + def requires(self, graph_module: GraphModule) -> None: # noqa: B027 """ This function will be called before the pass is run and will check that the given graph module contains the preconditions needed to run the @@ -66,7 +63,7 @@ class PassBase(abc.ABC): """ pass - def ensures(self, graph_module: GraphModule) -> None: + def ensures(self, graph_module: GraphModule) -> None: # noqa: B027 """ This function will be called after the pass is run and will check that the given graph module contains the postconditions needed to run the diff --git a/torch/nn/utils/prune.py b/torch/nn/utils/prune.py index 702c7fa29c9..81e9dcadfd5 100644 --- a/torch/nn/utils/prune.py +++ b/torch/nn/utils/prune.py @@ -17,9 +17,6 @@ class BasePruningMethod(ABC): """ _tensor_name: str - def __init__(self): - pass - def __call__(self, module, inputs): r"""Multiplies the mask (stored in ``module[name + '_mask']``) into the original tensor (stored in ``module[name + '_orig']``) diff --git a/torch/testing/_internal/distributed/rpc/rpc_agent_test_fixture.py b/torch/testing/_internal/distributed/rpc/rpc_agent_test_fixture.py index 5821ae7c10b..e8196135922 100644 --- a/torch/testing/_internal/distributed/rpc/rpc_agent_test_fixture.py +++ b/torch/testing/_internal/distributed/rpc/rpc_agent_test_fixture.py @@ -35,7 +35,7 @@ class RpcAgentTestFixture(ABC): def rpc_backend_options(self): pass - def setup_fault_injection(self, faulty_messages, messages_to_delay): + def setup_fault_injection(self, faulty_messages, messages_to_delay): # noqa: B027 """Method used by dist_init to prepare the faulty agent. Does nothing for other agents.