[BE] f-stringify torch/ and scripts (#105538)

This PR is a follow up on the pyupgrade series to convert more strings to use f-strings using `flynt`.

- https://docs.python.org/3/reference/lexical_analysis.html#f-strings
- https://pypi.org/project/flynt/

Command used:

```
flynt torch/ -ll 120
flynt scripts/ -ll 120
flynt tools/ -ll 120
```

and excluded `collect_env.py`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/105538
Approved by: https://github.com/ezyang, https://github.com/malfet
This commit is contained in:
Justin Chu
2023-07-21 08:23:48 -07:00
committed by PyTorch MergeBot
parent 4c73016ff2
commit 4cc1745b13
139 changed files with 350 additions and 670 deletions

View File

@ -124,7 +124,7 @@ class UnsupportedNodeError(NotSupportedError):
offending_node.col_offset,
offending_node.col_offset + range_len)
feature_name = pretty_node_names.get(node_type, node_type.__name__)
msg = "{} {}aren't supported".format(feature_name, reason + ' ' if reason else '')
msg = f"{feature_name} {reason + ' ' if reason else ''}aren't supported"
super().__init__(source_range, msg)
@ -889,8 +889,7 @@ class ExprBuilder(Builder):
sub_exprs.append(Dots(base.range()))
else:
raise NotSupportedError(base.range(),
"slicing multiple dimensions with "
"{} not supported".format(sub_type))
f"slicing multiple dimensions with {sub_type} not supported")
return sub_exprs
base = build_expr(ctx, expr.value)
sub_type = type(expr.slice)