Skip to content

Commit 52f6d4a

Browse files
XuehaiPanpytorchmergebot
authored andcommitted
[BE][CI][Easy] bump ruff to 0.9.0: long statements in docstrings (pytorch#146509)
Pull Request resolved: pytorch#146509 Approved by: https://github.com/justinchuby, https://github.com/Skylion007
1 parent 9605c50 commit 52f6d4a

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

torch/hub.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,11 @@ def _load_local(hubconf_dir, model, *args, **kwargs):
666666
Example:
667667
>>> # xdoctest: +SKIP("stub local path")
668668
>>> path = "/some/local/path/pytorch/vision"
669-
>>> model = _load_local(path, "resnet50", weights="ResNet50_Weights.IMAGENET1K_V1")
669+
>>> model = _load_local(
670+
... path,
671+
... "resnet50",
672+
... weights="ResNet50_Weights.IMAGENET1K_V1",
673+
... )
670674
"""
671675
with _add_to_sys_path(hubconf_dir):
672676
hubconf_path = os.path.join(hubconf_dir, MODULE_HUBCONF)

torch/onnx/_internal/fx/fx_symbolic_graph_extractor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def f(x):
153153
return out
154154
155155
156-
f = fx.symbolic_trace(f, concrete_args={"x": {"a": fx.PH, "b": fx.PH, "c": fx.PH}})
156+
f = fx.symbolic_trace(
157+
f,
158+
concrete_args={"x": {"a": fx.PH, "b": fx.PH, "c": fx.PH}},
159+
)
157160
assert f({"a": 1, "b": 2, "c": 4}) == 7
158161
"""
159162

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,10 @@ class Modularize(_pass.Transform):
822822
... )
823823
>>> gm.print_readable()
824824
825-
>>> gm = passes.Modularize(infra.DiagnosticContext("test_context", "1.0"), gm).run()
825+
>>> gm = passes.Modularize(
826+
... infra.DiagnosticContext("test_context", "1.0"),
827+
... gm,
828+
... ).run()
826829
>>> gm.print_readable()
827830
828831
"""

torch/serialization.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,16 @@ def load(
13221322
>>> # xdoctest: +SKIP("undefined filepaths")
13231323
>>> torch.load("tensors.pt", weights_only=True)
13241324
# Load all tensors onto the CPU
1325-
>>> torch.load("tensors.pt", map_location=torch.device("cpu"), weights_only=True)
1325+
>>> torch.load(
1326+
... "tensors.pt",
1327+
... map_location=torch.device("cpu"),
1328+
... weights_only=True,
1329+
... )
13261330
# Load all tensors onto the CPU, using a function
13271331
>>> torch.load(
1328-
... "tensors.pt", map_location=lambda storage, loc: storage, weights_only=True
1332+
... "tensors.pt",
1333+
... map_location=lambda storage, loc: storage,
1334+
... weights_only=True,
13291335
... )
13301336
# Load all tensors onto GPU 1
13311337
>>> torch.load(
@@ -1334,7 +1340,11 @@ def load(
13341340
... weights_only=True,
13351341
... ) # type: ignore[attr-defined]
13361342
# Map tensors from GPU 1 to GPU 0
1337-
>>> torch.load("tensors.pt", map_location={"cuda:1": "cuda:0"}, weights_only=True)
1343+
>>> torch.load(
1344+
... "tensors.pt",
1345+
... map_location={"cuda:1": "cuda:0"},
1346+
... weights_only=True,
1347+
... )
13381348
# Load tensor from io.BytesIO object
13391349
# Loading from a buffer setting weights_only=False, warning this can be unsafe
13401350
>>> with open("tensor.pt", "rb") as f:

0 commit comments

Comments
 (0)