You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
code='''if attn_output.size() != (size := (batch_size, self.num_heads, query.shape[1], self.head_dim)): raise ValueError(f"`attn_output` should be of size {size}, but is {attn_output.size()}")'''print(astroid.extract_node(code).as_string())
Running the above code produces the output
if attn_output.size() != size := (batch_size, self.num_heads, query.shape[1], self.head_dim):
raise ValueError(f'`attn_output` should be of size {size}, but is {attn_output.size()}')
This is incorrect since the brackets in the assignment operator are dropped and the syntax becomes incorrect.
Another example of dropping brackets:
code='''collections.OrderedDict( { 'linear': torch.nn.Linear(in_features, out_features, bias=bias), **( { 'norm': TorchNorm(out_features), 'act': TorchActivation(), } if not (i == len(layer_sizes) - 2 and not activate_final) else {} ), })'''print(astroid.extract_node(code).as_string())
outputs:
collections.OrderedDict({'linear': torch.nn.Linear(in_features, out_features, bias=bias), **{'norm': TorchNorm(out_features), 'act': TorchActivation()} if not (i == len(layer_sizes) - 2 and not activate_final) else {}})
Brackets following the ** operator are missing and syntax becomes incorrect
Python version: 3.10
astroid version: 3.3.6
The text was updated successfully, but these errors were encountered:
Running the above code produces the output
This is incorrect since the brackets in the assignment operator are dropped and the syntax becomes incorrect.
Another example of dropping brackets:
outputs:
Brackets following the
**
operator are missing and syntax becomes incorrectPython version: 3.10
astroid version: 3.3.6
The text was updated successfully, but these errors were encountered: