mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[8/N] Apply ruff UP035 rule (#165214)
This is follow-up of #164653 to continue applying `UP035` fixes. The purpose is to finally enable this rule. Pull Request resolved: https://github.com/pytorch/pytorch/pull/165214 Approved by: https://github.com/ezyang
This commit is contained in:
committed by
PyTorch MergeBot
parent
36871622f1
commit
b11593c31b
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Callable
|
from collections.abc import Callable
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn.functional as F
|
import torch.nn.functional as F
|
||||||
|
@ -35,7 +35,8 @@ from torch.fx.experimental.rewriter import RewritingTracer
|
|||||||
from torch.fx.operator_schemas import get_signature_for_torch_op
|
from torch.fx.operator_schemas import get_signature_for_torch_op
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from typing import Any, Callable, NamedTuple, Optional, Union
|
from typing import Any, NamedTuple, Optional, Union
|
||||||
|
from collections.abc import Callable
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
|
@ -12,7 +12,8 @@ import tempfile
|
|||||||
import typing
|
import typing
|
||||||
import unittest
|
import unittest
|
||||||
from types import BuiltinFunctionType
|
from types import BuiltinFunctionType
|
||||||
from typing import Callable, NamedTuple, Optional, Union
|
from typing import NamedTuple, Optional, Union
|
||||||
|
from collections.abc import Callable
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.fx.experimental.meta_tracer
|
import torch.fx.experimental.meta_tracer
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
# Copyright (c) Meta Platforms, Inc. and affiliates
|
# Copyright (c) Meta Platforms, Inc. and affiliates
|
||||||
import logging
|
import logging
|
||||||
import operator
|
import operator
|
||||||
from typing import Any, Optional, Sequence
|
from collections.abc import Sequence
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch.fx.node import map_aggregate
|
from torch.fx.node import map_aggregate
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
from typing import Any, Callable, TypeVar
|
from collections.abc import Callable
|
||||||
|
from typing import Any, TypeVar
|
||||||
|
|
||||||
|
|
||||||
_BACK_COMPAT_OBJECTS: dict[Any, None] = {}
|
_BACK_COMPAT_OBJECTS: dict[Any, None] = {}
|
||||||
|
@ -3,7 +3,8 @@ import importlib
|
|||||||
import io
|
import io
|
||||||
import pickle
|
import pickle
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from typing import Any, Callable, NewType, Optional, TypeVar, Union
|
from collections.abc import Callable
|
||||||
|
from typing import Any, NewType, Optional, TypeVar, Union
|
||||||
from typing_extensions import override, Self
|
from typing_extensions import override, Self
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from typing import Any, Callable, Optional, TypeVar
|
from collections.abc import Callable
|
||||||
|
from typing import Any, Optional, TypeVar
|
||||||
from typing_extensions import NamedTuple
|
from typing_extensions import NamedTuple
|
||||||
|
|
||||||
import torch.return_types
|
import torch.return_types
|
||||||
|
@ -9,10 +9,10 @@ import logging
|
|||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import warnings
|
import warnings
|
||||||
|
from collections.abc import Callable
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from types import CodeType, FunctionType, ModuleType
|
from types import CodeType, FunctionType, ModuleType
|
||||||
from typing import Any, Callable, get_args, NamedTuple, Optional, Union
|
from typing import Any, get_args, NamedTuple, Optional, TypeAlias, Union
|
||||||
from typing_extensions import TypeAlias
|
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.utils._pytree as pytree
|
import torch.utils._pytree as pytree
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
from typing import Any, Callable, Union
|
from collections.abc import Callable
|
||||||
|
from typing import Any, Union
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch.utils._pytree import tree_flatten_with_path, tree_map
|
from torch.utils._pytree import tree_flatten_with_path, tree_map
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# mypy: allow-untyped-defs
|
# mypy: allow-untyped-defs
|
||||||
import re
|
import re
|
||||||
from typing import Callable, Optional, Union
|
from collections.abc import Callable
|
||||||
|
from typing import Optional, Union
|
||||||
|
|
||||||
import torch.fx
|
import torch.fx
|
||||||
from torch.fx.node import map_arg
|
from torch.fx.node import map_arg
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# mypy: allow-untyped-defs
|
# mypy: allow-untyped-defs
|
||||||
import itertools
|
import itertools
|
||||||
import operator
|
import operator
|
||||||
|
from collections.abc import Callable
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from typing import Callable, TypeVar
|
from typing import TypeVar
|
||||||
from typing_extensions import ParamSpec
|
from typing_extensions import ParamSpec
|
||||||
|
|
||||||
import sympy
|
import sympy
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
import builtins
|
import builtins
|
||||||
import functools
|
import functools
|
||||||
import warnings
|
import warnings
|
||||||
from typing import Any, Callable, Optional, Union
|
from collections.abc import Callable
|
||||||
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.fx
|
import torch.fx
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# mypy: allow-untyped-defs
|
# mypy: allow-untyped-defs
|
||||||
import operator
|
import operator
|
||||||
import warnings
|
import warnings
|
||||||
from collections.abc import Iterable
|
from collections.abc import Callable, Iterable
|
||||||
from typing import Callable, TypeVar
|
from typing import TypeVar
|
||||||
from typing_extensions import ParamSpec
|
from typing_extensions import ParamSpec
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# mypy: ignore-errors
|
# mypy: ignore-errors
|
||||||
import copy
|
import copy
|
||||||
import itertools
|
import itertools
|
||||||
from typing import Callable
|
from collections.abc import Callable
|
||||||
|
|
||||||
from torch.fx.experimental.migrate_gradual_types.constraint import (
|
from torch.fx.experimental.migrate_gradual_types.constraint import (
|
||||||
ApplyBroadcasting,
|
ApplyBroadcasting,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# mypy: allow-untyped-defs
|
# mypy: allow-untyped-defs
|
||||||
import operator
|
import operator
|
||||||
from typing import Any, Callable, Optional
|
from collections.abc import Callable
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.fx
|
import torch.fx
|
||||||
|
@ -16,12 +16,12 @@ import typing
|
|||||||
import typing_extensions
|
import typing_extensions
|
||||||
import weakref
|
import weakref
|
||||||
from collections import defaultdict, OrderedDict
|
from collections import defaultdict, OrderedDict
|
||||||
from collections.abc import Generator, Mapping, Sequence
|
from collections.abc import Callable, Generator, Mapping, Sequence
|
||||||
from contextlib import _GeneratorContextManager, contextmanager, ExitStack, nullcontext
|
from contextlib import _GeneratorContextManager, contextmanager, ExitStack, nullcontext
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
Callable,
|
Concatenate,
|
||||||
Optional,
|
Optional,
|
||||||
overload,
|
overload,
|
||||||
Protocol,
|
Protocol,
|
||||||
@ -29,7 +29,7 @@ from typing import (
|
|||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
from typing_extensions import Concatenate, ParamSpec, Self, TypeVarTuple, Unpack
|
from typing_extensions import ParamSpec, Self, TypeVarTuple, Unpack
|
||||||
from weakref import WeakKeyDictionary
|
from weakref import WeakKeyDictionary
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
@ -3,8 +3,9 @@ import functools
|
|||||||
import inspect
|
import inspect
|
||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Callable, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.utils._pytree as pytree
|
import torch.utils._pytree as pytree
|
||||||
|
@ -5,8 +5,9 @@ import copy
|
|||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from collections.abc import Callable
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
from typing import Any, Callable, cast, Optional, Union
|
from typing import Any, cast, Optional, Union
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch._sources import normalize_source_lines
|
from torch._sources import normalize_source_lines
|
||||||
|
@ -31,23 +31,24 @@ import sys
|
|||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
from collections import Counter, defaultdict
|
from collections import Counter, defaultdict
|
||||||
from collections.abc import Generator, Iterator, Mapping, Sequence
|
from collections.abc import Callable, Generator, Iterator, Mapping, Sequence
|
||||||
from contextlib import _GeneratorContextManager, contextmanager
|
from contextlib import _GeneratorContextManager, contextmanager
|
||||||
from dataclasses import asdict, dataclass, field
|
from dataclasses import asdict, dataclass, field
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
Callable,
|
|
||||||
cast,
|
cast,
|
||||||
Generic,
|
Generic,
|
||||||
NamedTuple,
|
NamedTuple,
|
||||||
NoReturn,
|
NoReturn,
|
||||||
Optional,
|
Optional,
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
|
TypeAlias,
|
||||||
|
TypeGuard,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
from typing_extensions import deprecated, ParamSpec, TypeAlias, TypeGuard
|
from typing_extensions import deprecated, ParamSpec
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.fx
|
import torch.fx
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# mypy: allow-untyped-defs
|
# mypy: allow-untyped-defs
|
||||||
import inspect
|
import inspect
|
||||||
from typing import Any, Callable, TypeVar
|
from collections.abc import Callable
|
||||||
|
from typing import Any, TypeVar
|
||||||
from typing_extensions import TypeVarTuple, Unpack
|
from typing_extensions import TypeVarTuple, Unpack
|
||||||
|
|
||||||
from .dispatcher import Dispatcher, MethodDispatcher
|
from .dispatcher import Dispatcher, MethodDispatcher
|
||||||
|
@ -4,8 +4,9 @@ import functools
|
|||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import operator
|
import operator
|
||||||
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Callable, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
import sympy
|
import sympy
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@ import re
|
|||||||
import typing
|
import typing
|
||||||
import warnings
|
import warnings
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections.abc import Iterable, Iterator
|
from collections.abc import Callable, Iterable, Iterator
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Callable, Literal, NamedTuple, Optional, TYPE_CHECKING
|
from typing import Any, Literal, NamedTuple, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.utils._pytree as pytree
|
import torch.utils._pytree as pytree
|
||||||
|
@ -7,8 +7,9 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import warnings
|
import warnings
|
||||||
|
from collections.abc import Callable
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Callable, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
@ -4,9 +4,9 @@ import inspect
|
|||||||
import logging
|
import logging
|
||||||
import operator
|
import operator
|
||||||
import types
|
import types
|
||||||
from collections.abc import Iterable, Mapping, Sequence
|
from collections.abc import Callable, Iterable, Mapping, Sequence
|
||||||
from typing import Any, Callable, Optional, TYPE_CHECKING, Union
|
from typing import Any, Optional, TYPE_CHECKING, TypeAlias, Union
|
||||||
from typing_extensions import ParamSpec, TypeAlias, TypeVar
|
from typing_extensions import ParamSpec, TypeVar
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch._C import _fx_map_aggregate, _fx_map_arg, _NodeBase
|
from torch._C import _fx_map_aggregate, _fx_map_arg, _NodeBase
|
||||||
|
@ -5,7 +5,8 @@ import numbers
|
|||||||
import types
|
import types
|
||||||
import typing
|
import typing
|
||||||
import warnings
|
import warnings
|
||||||
from typing import Any, Callable, cast, NamedTuple, Optional, TYPE_CHECKING
|
from collections.abc import Callable
|
||||||
|
from typing import Any, cast, NamedTuple, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch._jit_internal import boolean_dispatched
|
from torch._jit_internal import boolean_dispatched
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# mypy: allow-untyped-defs
|
# mypy: allow-untyped-defs
|
||||||
import os
|
import os
|
||||||
from typing import Callable, Optional, TypeVar
|
from collections.abc import Callable
|
||||||
|
from typing import Optional, TypeVar
|
||||||
|
|
||||||
from torch.fx import Graph, Node
|
from torch.fx import Graph, Node
|
||||||
from torch.fx._compatibility import compatibility
|
from torch.fx._compatibility import compatibility
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# mypy: allow-untyped-defs
|
# mypy: allow-untyped-defs
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
|
from collections.abc import Callable
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from typing import Callable
|
|
||||||
|
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
from torch.fx._compatibility import compatibility
|
from torch.fx._compatibility import compatibility
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# mypy: allow-untyped-defs
|
# mypy: allow-untyped-defs
|
||||||
import logging
|
import logging
|
||||||
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Callable, cast, Optional
|
from typing import Any, cast, Optional
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.fx
|
import torch.fx
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from typing import Any, Callable
|
from collections.abc import Callable
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# mypy: allow-untyped-defs
|
# mypy: allow-untyped-defs
|
||||||
import logging
|
import logging
|
||||||
|
from collections.abc import Callable
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from inspect import unwrap
|
from inspect import unwrap
|
||||||
from typing import Callable, Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
import _operator
|
import _operator
|
||||||
import itertools
|
import itertools
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from collections.abc import Callable
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Callable
|
from typing import Any
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch._subclasses.fake_tensor import FakeTensor, FakeTensorMode
|
from torch._subclasses.fake_tensor import FakeTensor, FakeTensorMode
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, Callable, Optional
|
from collections.abc import Callable
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch.fx._compatibility import compatibility
|
from torch.fx._compatibility import compatibility
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Any, Callable, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from torch.fx._compatibility import compatibility
|
from torch.fx._compatibility import compatibility
|
||||||
from torch.fx.graph import Graph
|
from torch.fx.graph import Graph
|
||||||
|
@ -10,9 +10,9 @@ import operator
|
|||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from collections.abc import Iterator
|
from collections.abc import Callable, Iterator
|
||||||
from dataclasses import fields, is_dataclass
|
from dataclasses import fields, is_dataclass
|
||||||
from typing import Any, Callable, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.fx.traceback as fx_traceback
|
import torch.fx.traceback as fx_traceback
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import copy
|
import copy
|
||||||
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Callable, NamedTuple, Optional, TYPE_CHECKING, Union
|
from typing import Any, NamedTuple, Optional, TYPE_CHECKING, Union
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user