mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE][CI] bump ruff
to 0.9.0: string quote styles (#144569)
Reference: https://docs.astral.sh/ruff/formatter/#f-string-formatting - Change the outer quotes to double quotes for nested f-strings ```diff - f'{", ".join(args)}' + f"{', '.join(args)}" ``` - Change the inner quotes to double quotes for triple f-strings ```diff string = """ - {', '.join(args)} + {", ".join(args)} """ ``` - Join implicitly concatenated strings ```diff - string = "short string " "short string " f"{var}" + string = f"short string short string {var}" ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/144569 Approved by: https://github.com/Skylion007 ghstack dependencies: #146509
This commit is contained in:
committed by
PyTorch MergeBot
parent
52f6d4aa30
commit
754fb834db
@ -723,7 +723,7 @@ def emit_structseq_call(
|
||||
tn_key = gen_structseq_typename_key(overload.function)
|
||||
typename = typenames.get(tn_key)
|
||||
if typename is None:
|
||||
typename = f'NamedTuple{"" if not typedefs else len(typedefs)}'
|
||||
typename = f"NamedTuple{'' if not typedefs else len(typedefs)}"
|
||||
typenames[tn_key] = typename
|
||||
typedefs.append(
|
||||
f"""\
|
||||
@ -759,7 +759,7 @@ def generate_return_type_definition_and_registrations(
|
||||
typename = typenames.get(tn_key)
|
||||
|
||||
if typename is None:
|
||||
typename = f'{name}NamedTuple{"" if not definitions else len(definitions)}'
|
||||
typename = f"{name}NamedTuple{'' if not definitions else len(definitions)}"
|
||||
typenames[tn_key] = typename
|
||||
definitions.append(
|
||||
f"""\
|
||||
@ -807,7 +807,7 @@ def generate_return_type_declarations(
|
||||
|
||||
if typename is None:
|
||||
typename = (
|
||||
f'{name}NamedTuple{"" if not declarations else len(declarations)}'
|
||||
f"{name}NamedTuple{'' if not declarations else len(declarations)}"
|
||||
)
|
||||
typenames[tn_key] = typename
|
||||
declarations.append(f"PyTypeObject* get_{name}_structseq();")
|
||||
@ -1351,7 +1351,7 @@ def emit_single_dispatch(
|
||||
or (ps.method and ("requires_grad" in parser_outputs))
|
||||
)
|
||||
set_requires_grad = (
|
||||
f'.set_requires_grad({parser_outputs["requires_grad"].expr})'
|
||||
f".set_requires_grad({parser_outputs['requires_grad'].expr})"
|
||||
if need_set_requires_grad
|
||||
else ""
|
||||
)
|
||||
|
Reference in New Issue
Block a user