8000 [BE][Easy][19/19] enforce style for empty lines in import segments in… · pytorch/pytorch@3029331 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3029331

Browse files
XuehaiPanpytorchmergebot
authored andcommitted
[BE][Easy][19/19] enforce style for empty lines in import segments in torch/[o-z]*/ (#129771)
See #129751 (comment). Most changes are auto-generated by linter. You can review these PRs via: ```bash git diff --ignore-all-space --ignore-blank-lines HEAD~1 ``` Pull Request resolved: #129771 Approved by: https://github.com/justinchuby, https://github.com/janeyx99
1 parent c59f3ff commit 3029331

File tree

120 files changed

+162
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+162
-100
lines changed

tools/linter/adapters/ufmt_linter.py

Lines changed: 0 addition F438 s & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
# torch/[e-n]*/**
5757
"torch/[e-n]*/**",
5858
# torch/[o-z]*/**
59-
"torch/[o-z]*/**",
6059
],
6160
),
6261
)

torch/onnx/__init__.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,29 @@
33
from torch._C import _onnx as _C_onnx
44
from torch._C._onnx import OperatorExportTypes, TensorProtoDataType, TrainingMode
55

6-
from . import ( # usort:skip. Keep the order instead of sorting lexicographically
6+
from ._exporter_states import ExportTypes
7+
from ._internal.onnxruntime import (
8+
is_onnxrt_backend_supported,
9+
OrtBackend as _OrtBackend,
10+
OrtBackendOptions as _OrtBackendOptions,
11+
OrtExecutionProvider as _OrtExecutionProvider,
12+
)
13+
from ._type_utils import JitScalarType
14+
from .errors import CheckerError # Backwards compatibility
15+
from .utils import (
16+
_optimize_graph,
17+
_run_symbolic_function,
18+
_run_symbolic_method,
19+
export,
20+
export_to_pretty_string,
21+
is_in_onnx_export,
22+
register_custom_op_symbolic,
23+
select_model_mode_for_export,
24+
unregister_custom_op_symbolic,
25+
)
26+
27+
28+
from . import ( # usort: skip. Keep the order instead of sorting lexicographically
729
_deprecation,
830
errors,
931
symbolic_caffe2,
@@ -25,22 +47,8 @@
2547
utils,
2648
)
2749

28-
from ._exporter_states import ExportTypes
29-
from ._type_utils import JitScalarType
30-
from .errors import CheckerError # Backwards compatibility
31-
from .utils import (
32-
_optimize_graph,
33-
_run_symbolic_function,
34-
_run_symbolic_method,
35-
export,
36-
export_to_pretty_string,
37-
is_in_onnx_export,
38-
register_custom_op_symbolic,
39-
select_model_mode_for_export,
40-
unregister_custom_op_symbolic,
41-
)
4250

43-
from ._internal.exporter import ( # usort:skip. needs to be last to avoid circular import
51+
from ._internal.exporter import ( # usort: skip. needs to be last to avoid circular import
4452
DiagnosticOptions,
4553
ExportOptions,
4654
ONNXProgram,
@@ -53,12 +61,6 @@
5361
enable_fake_mode,
5462
)
5563

56-
from ._internal.onnxruntime import (
57-
is_onnxrt_backend_supported,
58-
OrtBackend as _OrtBackend,
59-
OrtBackendOptions as _OrtBackendOptions,
60-
OrtExecutionProvider as _OrtExecutionProvider,
61-
)
6264

6365
__all__ = [
6466
# Modules

torch/onnx/_deprecation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Callable, TypeVar
77
from typing_extensions import ParamSpec
88

9+
910
_T = TypeVar("_T")
1011
_P = ParamSpec("_P")
1112

torch/onnx/_internal/diagnostics/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from ._rules import rules
1010
from .infra import levels
1111

12+
1213
__all__ = [
1314
"TorchScriptOnnxExportDiagnostic",
1415
"ExportDiagnosticEngine",

torch/onnx/_internal/diagnostics/_diagnostic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
from typing import TYPE_CHECKING
88

99
import torch
10-
1110
from torch.onnx._internal.diagnostics import infra
1211
from torch.onnx._internal.diagnostics.infra import formatter, sarif
1312
from torch.onnx._internal.diagnostics.infra.sarif import version as sarif_version
1413
from torch.utils import cpp_backtrace
1514

15+
1616
if TYPE_CHECKING:
1717
from collections.abc import Generator
1818

torch/onnx/_internal/diagnostics/_rules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# flake8: noqa
1414
from torch.onnx._internal.diagnostics import infra
1515

16+
< 10000 /td>
1617
"""
1718
GENERATED CODE - DO NOT EDIT DIRECTLY
1819
The purpose of generating a class for each rule is to override the `format_message`

torch/onnx/_internal/diagnostics/infra/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
)
1515
from .context import Diagnostic, DiagnosticContext, RuntimeErrorWithDiagnostic
1616

17+
1718
__all__ = [
1819
"Diagnostic",
1920
"DiagnosticContext",

torch/onnx/_internal/diagnostics/infra/context.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
from __future__ import annotations
55

66
import contextlib
7-
87
import dataclasses
98
import gzip
10-
119
import logging
12-
1310
from typing import Callable, Generator, Generic, Literal, Mapping, TypeVar
14-
1511
from typing_extensions import Self
1612

1713
from torch.onnx._internal.diagnostics import infra

torch/onnx/_internal/diagnostics/infra/formatter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from typing import Any, Callable, Union
88

99
from torch._logging import LazyString
10-
1110
from torch.onnx._internal.diagnostics.infra import sarif
1211

1312

torch/onnx/_internal/diagnostics/infra/sarif/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,5 @@
9797
from torch.onnx._internal.diagnostics.infra.sarif._web_request import WebRequest
9898
from torch.onnx._internal.diagnostics.infra.sarif._web_response import WebResponse
9999

100+
100101
# flake8: noqa
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Final
22

3+
34
SARIF_VERSION: Final = "2.1.0"
45
SARIF_SCHEMA_LINK: Final = "https://docs.oasis-open.org/sarif/sarif/v2.1.0/cs01/schemas/sarif-schema-2.1.0.json"
56
# flake8: noqa

torch/onnx/_internal/diagnostics/infra/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import functools
4-
54
import inspect
65
import traceback
76
from typing import Any, Callable, Mapping, Sequence

torch/onnx/_internal/exporter.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
)
55

66
import abc
7-
87
import contextlib
98
import dataclasses
109
import logging
1110
import os
12-
1311
import tempfile
1412
import warnings
1513
from collections import defaultdict
@@ -27,11 +25,9 @@
2725
from typing_extensions import Self
2826

2927
import torch
30-
3128
import torch._ops
3229
import torch.export as torch_export
3330
import torch.utils._pytree as pytree
34-
3531
from torch.onnx._internal import io_adapter
3632
from torch.onnx._internal.diagnostics import infra
3733
from torch.onnx._internal.fx import (
@@ -41,21 +37,22 @@
4137
serialization as fx_serialization,
4238
)
4339

40+
4441
# We can only import onnx from this module in a type-checking context to ensure that
4542
# 'import torch.onnx' continues to work without having 'onnx' installed. We fully
4643
# 'import onnx' inside of dynamo_export (by way of _assert_dependencies).
4744
if TYPE_CHECKING:
4845
import io
4946

5047
import onnx
48+
5149
import onnxruntime # type: ignore[import]
5250
import onnxscript # type: ignore[import]
5351
from onnxscript.function_libs.torch_lib import ( # type: ignore[import]
5452
registration as torchlib_registry,
5553
)
5654

5755
from torch._subclasses import fake_tensor
58-
5956
from torch.onnx._internal.fx import diagnostics
6057

6158
_DEFAULT_OPSET_VERSION: Final[int] = 18

torch/onnx/_internal/fx/_pass.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@
22
from __future__ import annotations
33

44< F438 /code>
import abc
5-
65
import contextlib
76
import dataclasses
87
import difflib
9-
108
import io
119
import logging
1210
import sys
13-
1411
from typing import Any, Callable, TYPE_CHECKING
1512

1613
import torch
1714
import torch.fx
1815
from torch.fx.experimental.proxy_tensor import maybe_disable_fake_tensor_mode
19-
2016
from torch.onnx._internal.fx import diagnostics, onnxfunction_dispatcher
2117

18+
2219
if TYPE_CHECKING:
2320
from torch._subclasses import fake_tensor
2421

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .unsupported_nodes import UnsupportedFxNodesAnalysis
22

3+
34
__all__ = [
45
"UnsupportedFxNodesAnalysis",
56
]

torch/onnx/_internal/fx/decomposition_skip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import abc
1717
import contextlib
18-
1918
from typing import Callable, Sequence
2019

2120
from onnxscript.function_libs.torch_lib.ops import ( # type: ignore[import-not-found]
@@ -26,6 +25,7 @@
2625
import torch
2726
from torch._decomp import decompositions
2827

28+
2929
_NEW_OP_NAMESPACE: str = "onnx_export"
3030
"""The namespace for the custom operator."""
3131

torch/onnx/_internal/fx/decomposition_table.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import torch
99
import torch._ops
1010
import torch.fx
11-
1211
from torch.onnx._internal.fx import registration
1312

1413

torch/onnx/_internal/fx/diagnostics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
from __future__ import annotations
33

44
import dataclasses
5-
65
import functools
7-
86
from typing import Any, TYPE_CHECKING
97

108
import onnxscript # type: ignore[import]
@@ -17,6 +15,7 @@
1715
from torch.onnx._internal.diagnostics.infra import decorator, formatter
1816
from torch.onnx._internal.fx import registration, type_utils as fx_type_utils
1917

18+
2019
if TYPE_CHECKING:
2120
import logging
2221

torch/onnx/_internal/fx/fx_onnx_interpreter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import torch
1717
import torch.fx
1818
from torch.onnx import _type_utils as jit_type_utils
19-
2019
from torch.onnx._internal.fx import (
2120
_pass,
2221
diagnostics,

torch/onnx/_internal/fx/fx_symbolic_graph_extractor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
from __future__ import annotations
33

44
import functools
5-
65
from typing import Any, Callable, Mapping, Sequence
76

87
import torch
98
import torch.fx
109
import torch.onnx
11-
1210
import torch.onnx._internal.fx.passes as passes
1311
from torch.onnx._internal import exporter, io_adapter
1412

13+
1514
# Functions directly wrapped to produce torch.fx.Proxy so that symbolic
1615
# data can flow through those functions. Python functions (e.g., `torch.arange`)
1716
# not defined by pybind11 in C++ do not go though Python dispatcher, so

torch/onnx/_internal/fx/onnxfunction_dispatcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
import torch
1212
import torch._ops
1313
import torch.fx
14-
1514
from torch.onnx._internal.fx import (
1615
diagnostics,
1716
registration,
1817
type_utils as fx_type_utils,
1918
)
2019
10000
20+
2121
if TYPE_CHECKING:
2222
import onnxscript # type: ignore[import]
2323
from onnxscript.function_libs.torch_lib import ( # type: ignore[import]

torch/onnx/_internal/fx/op_validation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import torch.fx
1414
from torch.fx.experimental import symbolic_shapes
1515
from torch.onnx import _constants, _type_utils as jit_type_utils
16-
1716
from torch.onnx._internal.fx import (
1817
diagnostics,
1918
fx_onnx_interpreter,

torch/onnx/_internal/fx/passes/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .type_promotion import InsertTypePromotion
66
from .virtualization import MovePlaceholderToFront, ReplaceGetAttrWithPlaceholder
77

8+
89
__all__ = [
910
"Decompose",
1011
"InsertTypePromotion",

torch/onnx/_internal/fx/passes/_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
from __future__ import annotations
77

88
import collections
9-
109
import re
11-
1210
from typing import Callable
1311

1412
import torch.fx

tor 10000 ch/onnx/_internal/fx/passes/decomp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import annotations
33

44
import contextlib
5-
65
from typing import Callable, Mapping, TYPE_CHECKING
76

87
import torch
@@ -12,6 +11,7 @@
1211
from torch.onnx._internal.fx import _pass, diagnostics
1312
from torch.onnx._internal.fx.passes import _utils
1413

14+
1515
if TYPE_CHECKING:
1616
import torch.fx
1717
from torch._subclasses import fake_tensor

torch/onnx/_internal/fx/passes/functionalization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import annotations
33

44
import contextlib
5-
65
from typing import Callable, TYPE_CHECKING
76

87
import torch
@@ -14,6 +13,7 @@
1413
from torch.onnx._internal.fx.passes import _utils
1514
from torch.utils import _pytree as pytree
1615

16+
1717
if TYPE_CHECKING:
1818
from torch._subclasses import fake_tensor
1919

0 commit comments

Comments
 (0)
0