mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
[BE][CI] bump ruff
to 0.9.2: multiline assert
statements (#144546)
Reference: https://docs.astral.sh/ruff/formatter/black/#assert-statements > Unlike Black, Ruff prefers breaking the message over breaking the assertion, similar to how both Ruff and Black prefer breaking the assignment value over breaking the assignment target: > > ```python > # Input > assert ( > len(policy_types) >= priority + num_duplicates > ), f"This tests needs at least {priority+num_duplicates} many types." > > > # Black > assert ( > len(policy_types) >= priority + num_duplicates > ), f"This tests needs at least {priority+num_duplicates} many types." > > # Ruff > assert len(policy_types) >= priority + num_duplicates, ( > f"This tests needs at least {priority + num_duplicates} many types." > ) > ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/144546 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
f0d00421cf
commit
c73a92fbf5
@ -246,9 +246,9 @@ class FileManager:
|
||||
for key in sharded_keys:
|
||||
for shard in all_shards:
|
||||
if key in shard:
|
||||
assert isinstance(
|
||||
shard[key], list
|
||||
), "sharded keys in base_env must be a list"
|
||||
assert isinstance(shard[key], list), (
|
||||
"sharded keys in base_env must be a list"
|
||||
)
|
||||
shard[key] = shard[key].copy()
|
||||
else:
|
||||
shard[key] = []
|
||||
@ -441,9 +441,9 @@ class NamespaceHelper:
|
||||
) -> None:
|
||||
# cpp_namespace can be a colon joined string such as torch::lazy
|
||||
cpp_namespaces = namespace_str.split("::")
|
||||
assert (
|
||||
len(cpp_namespaces) <= max_level
|
||||
), f"Codegen doesn't support more than {max_level} level(s) of custom namespace. Got {namespace_str}."
|
||||
assert len(cpp_namespaces) <= max_level, (
|
||||
f"Codegen doesn't support more than {max_level} level(s) of custom namespace. Got {namespace_str}."
|
||||
)
|
||||
self.cpp_namespace_ = namespace_str
|
||||
self.prologue_ = "\n".join([f"namespace {n} {{" for n in cpp_namespaces])
|
||||
self.epilogue_ = "\n".join(
|
||||
|
Reference in New Issue
Block a user