Skip to content

Commit 873d743

Browse files
committed
Use f-strings in sphinx.util.typing
1 parent 09d05a0 commit 873d743

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sphinx/util/typing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def restify(cls: type | None, mode: str = 'fully-qualified-except-typing') -> st
184184
# newtypes have correct module info since Python 3.10+
185185
return f':py:class:`{modprefix}{cls.__module__}.{cls.__name__}`'
186186
else:
187-
return ':py:class:`%s`' % cls.__name__
187+
return f':py:class:`{cls.__name__}`'
188188
elif UnionType and isinstance(cls, UnionType):
189189
return ' | '.join(restify(a, mode) for a in cls.__args__)
190190
elif cls.__module__ in ('__builtin__', 'builtins'):
@@ -195,7 +195,7 @@ def restify(cls: type | None, mode: str = 'fully-qualified-except-typing') -> st
195195
concatenated_args = ', '.join(restify(arg, mode) for arg in cls.__args__)
196196
return fr':py:class:`{cls.__name__}`\ [{concatenated_args}]'
197197
else:
198-
return ':py:class:`%s`' % cls.__name__
198+
return f':py:class:`{cls.__name__}`'
199199
elif (inspect.isgenericalias(cls)
200200
and cls.__module__ == 'typing'
201201
and cls.__origin__ is Union): # type: ignore[attr-defined]
@@ -229,10 +229,10 @@ def restify(cls: type | None, mode: str = 'fully-qualified-except-typing') -> st
229229
literal_args.append(_format_literal_enum_arg(a, mode=mode))
230230
else:
231231
literal_args.append(repr(a))
232-
text += r"\ [%s]" % ', '.join(literal_args)
232+
text += fr"\ [{', '.join(literal_args)}]"
233233
del literal_args
234234
elif cls.__args__:
235-
text += r"\ [%s]" % ", ".join(restify(a, mode) for a in cls.__args__)
235+
text += fr"\ [{', '.join(restify(a, mode) for a in cls.__args__)}]"
236236

237237
return text
238238
elif isinstance(cls, typing._SpecialForm):
@@ -246,7 +246,7 @@ def restify(cls: type | None, mode: str = 'fully-qualified-except-typing') -> st
246246
else:
247247
return f':py:class:`{modprefix}{cls.__module__}.{cls.__qualname__}`'
248248
elif isinstance(cls, ForwardRef):
249-
return ':py:class:`%s`' % cls.__forward_arg__
249+
return f':py:class:`{cls.__forward_arg__}`'
250250
else:
251251
# not a class (ex. TypeVar)
252252
if cls.__module__ == 'typing':

0 commit comments

Comments
 (0)