mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE] Enable Ruff's Flake8 PYI045 (#111184)
Enable [iter-method-return-iterable (PYI045)](https://docs.astral.sh/ruff/rules/iter-method-return-iterable/#iter-method-return-iterable-pyi045) Link: #110950 Pull Request resolved: https://github.com/pytorch/pytorch/pull/111184 Approved by: https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
ba7b9211ee
commit
00d962631c
@ -51,7 +51,6 @@ ignore = [
|
|||||||
"PYI024",
|
"PYI024",
|
||||||
"PYI036",
|
"PYI036",
|
||||||
"PYI041",
|
"PYI041",
|
||||||
"PYI045",
|
|
||||||
"PYI056",
|
"PYI056",
|
||||||
"SIM102", "SIM103", "SIM112", # flake8-simplify code styles
|
"SIM102", "SIM103", "SIM112", # flake8-simplify code styles
|
||||||
"SIM105", # these ignores are from flake8-simplify. please fix or ignore with commented reason
|
"SIM105", # these ignores are from flake8-simplify. please fix or ignore with commented reason
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
"""The Pipe interface."""
|
"""The Pipe interface."""
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Union, Sequence, Tuple, cast
|
from typing import TYPE_CHECKING, Any, Iterable, Iterator, List, Optional, Union, Sequence, Tuple, cast
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch import Tensor, nn
|
from torch import Tensor, nn
|
||||||
@ -379,7 +379,7 @@ class Pipe(Module):
|
|||||||
|
|
||||||
raise IndexError
|
raise IndexError
|
||||||
|
|
||||||
def __iter__(self) -> Iterable[nn.Module]:
|
def __iter__(self) -> Iterator[nn.Module]:
|
||||||
"""Iterates over children of the underlying sequential module."""
|
"""Iterates over children of the underlying sequential module."""
|
||||||
for partition in self.partitions:
|
for partition in self.partitions:
|
||||||
yield from partition
|
yield from partition
|
||||||
|
@ -12,7 +12,7 @@ from dataclasses import is_dataclass, fields
|
|||||||
|
|
||||||
|
|
||||||
from .graph import magic_methods, reflectable_magic_methods, Graph
|
from .graph import magic_methods, reflectable_magic_methods, Graph
|
||||||
from typing import Tuple, Dict, OrderedDict, Optional, Iterable, Any, Iterator, Callable
|
from typing import Tuple, Dict, OrderedDict, Optional, Any, Iterator, Callable
|
||||||
from .node import Target, Node, Argument, base_types, map_aggregate
|
from .node import Target, Node, Argument, base_types, map_aggregate
|
||||||
from ._compatibility import compatibility
|
from ._compatibility import compatibility
|
||||||
from .operator_schemas import check_for_mutable_operation
|
from .operator_schemas import check_for_mutable_operation
|
||||||
@ -392,7 +392,7 @@ class Proxy:
|
|||||||
def __call__(self, *args, **kwargs) -> 'Proxy':
|
def __call__(self, *args, **kwargs) -> 'Proxy':
|
||||||
return self.tracer.create_proxy('call_method', '__call__', (self,) + args, kwargs)
|
return self.tracer.create_proxy('call_method', '__call__', (self,) + args, kwargs)
|
||||||
|
|
||||||
def __iter__(self) -> Iterable['Proxy']:
|
def __iter__(self) -> Iterator['Proxy']:
|
||||||
frame = inspect.currentframe()
|
frame = inspect.currentframe()
|
||||||
assert frame is not None
|
assert frame is not None
|
||||||
calling_frame = frame.f_back
|
calling_frame = frame.f_back
|
||||||
|
Reference in New Issue
Block a user