@@ -128,7 +128,7 @@ def _get_config(**kwargs):
128128 | {'module' , 'modules' , 'http_server' , 'external_links' , 'search_query' })
129129 invalid_keys = {k : v for k , v in kwargs .items () if k not in known_keys }
130130 if invalid_keys :
131- warn ('Unknown configuration variables (not in config.mako): {}' . format ( invalid_keys ) )
131+ warn (f 'Unknown configuration variables (not in config.mako): { invalid_keys } ' )
132132 config .update (kwargs )
133133
134134 if 'search_query' in config :
@@ -150,10 +150,9 @@ def _render_template(template_name, **kwargs):
150150 try :
151151 t = tpl_lookup .get_template (template_name )
152152 except TopLevelLookupException :
153- raise OSError (
154- "No template found at any of: {}" .format (
155- ', ' .join (path .join (p , template_name .lstrip ("/" ))
156- for p in tpl_lookup .directories )))
153+ paths = [path .join (p , template_name .lstrip ('/' )) for p in tpl_lookup .directories ]
154+ raise OSError (f"No template found at any of: { ', ' .join (paths )} " )
155+
157156 try :
158157 return t .render (** config ).strip ()
159158 except Exception :
@@ -224,8 +223,7 @@ def _module_path(module):
224223 try :
225224 module = importlib .import_module (module_path )
226225 except Exception as e :
227- raise ImportError ('Error importing {!r}: {}: {}'
228- .format (module , e .__class__ .__name__ , e ))
226+ raise ImportError (f'Error importing { module !r} : { e .__class__ .__name__ } : { e } ' )
229227
230228 assert inspect .ismodule (module )
231229 # If this is pdoc itself, return without reloading. Otherwise later
@@ -272,7 +270,7 @@ def _pep224_docstrings(doc_obj: Union['Module', 'Class'], *,
272270 # Don't emit a warning for builtins that don't have source available
273271 is_builtin = getattr (doc_obj .obj , '__module__' , None ) == 'builtins'
274272 if not is_builtin :
275- warn ("Couldn't read PEP-224 variable docstrings from {!r}: {}" . format ( doc_obj , exc ) ,
273+ warn (f "Couldn't read PEP-224 variable docstrings from { doc_obj !r} : { exc } " ,
276274 stacklevel = 3 + int (isinstance (doc_obj , Class )))
277275 return {}, {}
278276
@@ -409,7 +407,7 @@ def _toposort(graph: Mapping[T, Set[T]]) -> Generator[T, None, None]:
409407 yield from ordered
410408 if not ordered :
411409 break
412- assert not graph , "A cyclic dependency exists amongst %r" % graph
410+ assert not graph , f "A cyclic dependency exists amongst { graph !r } "
413411
414412
415413def link_inheritance (context : Context = None ):
@@ -492,7 +490,7 @@ def __init__(self, name, module, obj, docstring=None):
492490 """
493491
494492 def __repr__ (self ):
495- return '<{} {!r}>' . format ( self .__class__ .__name__ , self .refname )
493+ return f '<{ self .__class__ .__name__ } { self .refname !r } >'
496494
497495 @property # type: ignore
498496 @lru_cache ()
@@ -640,8 +638,8 @@ def __init__(self, module: Union[ModuleType, str], *, docfilter: Callable[[Doc],
640638 try :
641639 obj = getattr (self .obj , name )
642640 except AttributeError :
643- warn ("Module {!r} doesn't contain identifier `{}` "
644- "exported in `__all__`" . format ( self . module , name ) )
641+ warn (f "Module { self . module !r} doesn't contain identifier `{ name } ` "
642+ "exported in `__all__`" )
645643 if not _is_blacklisted (name , self ):
646644 obj = inspect .unwrap (obj )
647645 public_objs .append ((name , obj ))
@@ -703,7 +701,7 @@ def iter_modules(paths):
703701 continue
704702
705703 assert self .refname == self .name
706- fullname = "%s.%s" % ( self .name , root )
704+ fullname = f" { self .name } . { root } "
707705 try :
708706 m = Module (import_module (fullname ),
709707 docfilter = docfilter , supermodule = self ,
@@ -767,20 +765,20 @@ def _link_inheritance(self):
767765 if docstring is True :
768766 continue
769767
770- refname = "%s.%s" % ( self .refname , name )
768+ refname = f" { self .refname } . { name } "
771769 if docstring in (False , None ):
772770 if docstring is None :
773771 warn ('Setting `__pdoc__[key] = None` is deprecated; '
774772 'use `__pdoc__[key] = False` '
775- '(key: {!r}, module: {!r}).' . format ( name , self . name ) )
773+ f '(key: { name !r} , module: { self . name !r} ).' )
776774
777775 if name in self ._skipped_submodules :
778776 continue
779777
780778 if (not name .endswith ('.__init__' ) and
781779 name not in self .doc and refname not in self ._context ):
782- warn ('__pdoc__-overriden key {!r} does not exist '
783- 'in module {!r}' . format ( name , self . name ) )
780+ warn (f '__pdoc__-overriden key { name !r} does not exist '
781+ f 'in module { self . name !r} ' )
784782
785783 obj = self .find_ident (name )
786784 cls = getattr (obj , 'cls' , None )
@@ -800,8 +798,8 @@ def _link_inheritance(self):
800798 if isinstance (dobj , External ):
801799 continue
802800 if not isinstance (docstring , str ):
803- raise ValueError ('__pdoc__ dict values must be strings;'
804- '__pdoc__[{!r}] is of type {}' . format ( name , type (docstring )) )
801+ raise ValueError ('__pdoc__ dict values must be strings; '
802+ f '__pdoc__[{ name !r} ] is of type { type (docstring )} ' )
805803 dobj .docstring = inspect .cleandoc (docstring )
806804
807805 # Now after docstrings are set correctly, continue the
@@ -1044,7 +1042,7 @@ def _method_type(cls: type, name: str):
10441042 if isinstance (c .__dict__ [name ], staticmethod ):
10451043 return staticmethod
10461044 return None
1047- raise RuntimeError ("{ }.{} not found". format ( cls , name ) )
1045+ raise RuntimeError (f" { cls } .{ name } not found" )
10481046
10491047 @property
10501048 def refname (self ) -> str :
@@ -1307,7 +1305,7 @@ def return_annotation(self, *, link=None) -> str:
13071305 else :
13081306 # Don't warn on variables. The annotation just isn't available.
13091307 if not isinstance (self , Variable ):
1310- warn ("Error handling return annotation for {!r}" . format ( self ) , stacklevel = 3 )
1308+ warn (f "Error handling return annotation for { self !r} " , stacklevel = 3 )
13111309
13121310 if annot is inspect .Parameter .empty or not annot :
13131311 return ''
@@ -1469,10 +1467,10 @@ def _signature_from_string(self):
14691467 # See: https://github.com/pdoc3/pdoc/pull/148#discussion_r407114141
14701468 module_basename = self .module .name .rsplit ('.' , maxsplit = 1 )[- 1 ]
14711469 if module_basename in string and module_basename not in _globals :
1472- string = re .sub (r '(?<!\.)\b{}\.\b'. format ( module_basename ) , '' , string )
1470+ string = re .sub (fr '(?<!\.)\b{ module_basename } \.\b' , '' , string )
14731471
14741472 try :
1475- exec ('def {}: pass' . format ( string ) , _globals , _locals )
1473+ exec (f 'def { string } : pass' , _globals , _locals )
14761474 except SyntaxError :
14771475 continue
14781476 signature = inspect .signature (_locals [self .name ])
@@ -1565,4 +1563,4 @@ def url(self, *args, **kwargs):
15651563 """
15661564 `External` objects return absolute urls matching `/{name}.ext`.
15671565 """
1568- return '/%s.ext' % self .name
1566+ return f'/ { self .name } .ext'
0 commit comments