mirror of
https://github.com/pytorch/pytorch.git
synced 2025-11-11 22:34:53 +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
@ -84,9 +84,9 @@ class CompositeMHA(torch.nn.Module):
|
||||
|
||||
self.head_dim = embed_dim // num_heads
|
||||
self.embed_dim = embed_dim
|
||||
assert (
|
||||
self.head_dim * num_heads == self.embed_dim
|
||||
), "embed_dim must be divisible by num_heads"
|
||||
assert self.head_dim * num_heads == self.embed_dim, (
|
||||
"embed_dim must be divisible by num_heads"
|
||||
)
|
||||
|
||||
self.q_proj_weight = Parameter(
|
||||
torch.empty((embed_dim, embed_dim), **factory_kwargs)
|
||||
|
||||
@ -49,9 +49,9 @@ class ExperimentConfig:
|
||||
backends: list[str]
|
||||
|
||||
def __post_init__(self):
|
||||
assert (
|
||||
len(self.shape) == 6
|
||||
), "Shape must be of length 6" # [B, Hq, M, Hkv, N, D]
|
||||
assert len(self.shape) == 6, (
|
||||
"Shape must be of length 6"
|
||||
) # [B, Hq, M, Hkv, N, D]
|
||||
|
||||
def asdict(self):
|
||||
# Convert the dataclass instance to a dictionary
|
||||
|
||||
Reference in New Issue
Block a user