@@ -267,7 +267,7 @@ def _pep224_docstrings(doc_obj: Union['Module', 'Class'], *,
267
267
# Maybe raise exceptions with appropriate message
268
268
# before using cleaned doc_obj.source
269
269
_ = inspect .findsource (doc_obj .obj )
270
- tree = ast .parse (doc_obj .source ) # type: ignore
270
+ tree = ast .parse (doc_obj .source )
271
271
except (OSError , TypeError , SyntaxError ) as exc :
272
272
# Don't emit a warning for builtins that don't have source available
273
273
is_builtin = getattr (doc_obj .obj , '__module__' , None ) == 'builtins'
@@ -345,7 +345,7 @@ def get_name(assign_node):
345
345
def get_indent (line ):
346
346
return len (line ) - len (line .lstrip ())
347
347
348
- source_lines = doc_obj .source .splitlines () # type: ignore
348
+ source_lines = doc_obj .source .splitlines ()
349
349
assign_line = source_lines [assign_node .lineno - 1 ]
350
350
assign_indent = get_indent (assign_line )
351
351
comment_lines = []
@@ -451,7 +451,7 @@ def _toposort(graph: Mapping[T, Set[T]]) -> Generator[T, None, None]:
451
451
assert not graph , f"A cyclic dependency exists amongst { graph !r} "
452
452
453
453
454
- def link_inheritance (context : Context = None ):
454
+ def link_inheritance (context : Optional [ Context ] = None ):
455
455
"""
456
456
Link inheritance relationsships between `pdoc.Class` objects
457
457
(and between their members) of all `pdoc.Module` objects that
@@ -491,7 +491,7 @@ class Doc:
491
491
"""
492
492
__slots__ = ('module' , 'name' , 'obj' , 'docstring' , 'inherits' )
493
493
494
- def __init__ (self , name : str , module , obj , docstring : str = None ):
494
+ def __init__ (self , name : str , module , obj , docstring : str = '' ):
495
495
"""
496
496
Initializes a documentation object, where `name` is the public
497
497
identifier name, `module` is a `pdoc.Module` object where raw
@@ -566,7 +566,7 @@ def qualname(self) -> str:
566
566
return getattr (self .obj , '__qualname__' , self .name )
567
567
568
568
@lru_cache ()
569
- def url (self , relative_to : 'Module' = None , * , link_prefix : str = '' ,
569
+ def url (self , relative_to : Optional [ 'Module' ] = None , * , link_prefix : str = '' ,
570
570
top_ancestor : bool = False ) -> str :
571
571
"""
572
572
Canonical relative URL (including page fragment) for this
@@ -624,8 +624,10 @@ class Module(Doc):
624
624
__slots__ = ('supermodule' , 'doc' , '_context' , '_is_inheritance_linked' ,
625
625
'_skipped_submodules' )
626
626
627
- def __init__ (self , module : Union [ModuleType , str ], * , docfilter : Callable [[Doc ], bool ] = None ,
628
- supermodule : 'Module' = None , context : Context = None ,
627
+ def __init__ (self , module : Union [ModuleType , str ], * ,
628
+ docfilter : Optional [Callable [[Doc ], bool ]] = None ,
629
+ supermodule : Optional ['Module' ] = None ,
630
+ context : Optional [Context ] = None ,
629
631
skip_errors : bool = False ):
630
632
"""
631
633
Creates a `Module` documentation object given the actual
@@ -1010,7 +1012,7 @@ class Class(Doc):
1010
1012
"""
1011
1013
__slots__ = ('doc' , '_super_members' )
1012
1014
1013
- def __init__ (self , name : str , module : Module , obj , * , docstring : str = None ):
1015
+ def __init__ (self , name : str , module : Module , obj , * , docstring : Optional [ str ] = None ):
1014
1016
assert inspect .isclass (obj )
1015
1017
1016
1018
if docstring is None :
@@ -1317,7 +1319,7 @@ class Function(Doc):
1317
1319
"""
1318
1320
__slots__ = ('cls' ,)
1319
1321
1320
- def __init__ (self , name : str , module : Module , obj , * , cls : Class = None ):
1322
+ def __init__ (self , name : str , module : Module , obj , * , cls : Optional [ Class ] = None ):
1321
1323
"""
1322
1324
Same as `pdoc.Doc`, except `obj` must be a
1323
1325
Python function object. The docstring is gathered automatically.
@@ -1419,7 +1421,8 @@ def return_annotation(self, *, link=None) -> str:
1419
1421
s = re .sub (r'[\w\.]+' , partial (_linkify , link = link , module = self .module ), s )
1420
1422
return s
1421
1423
1422
- def params (self , * , annotate : bool = False , link : Callable [[Doc ], str ] = None ) -> List [str ]:
1424
+ def params (self , * , annotate : bool = False ,
1425
+ link : Optional [Callable [[Doc ], str ]] = None ) -> List [str ]:
1423
1426
"""
1424
1427
Returns a list where each element is a nicely formatted
1425
1428
parameter of this function. This includes argument lists,
@@ -1589,7 +1592,7 @@ class Variable(Doc):
1589
1592
__slots__ = ('cls' , 'instance_var' )
1590
1593
1591
1594
def __init__ (self , name : str , module : Module , docstring , * ,
1592
- obj = None , cls : Class = None , instance_var : bool = False ):
1595
+ obj = None , cls : Optional [ Class ] = None , instance_var : bool = False ):
1593
1596
"""
1594
1597
Same as `pdoc.Doc`, except `cls` should be provided
1595
1598
as a `pdoc.Class` object when this is a class or instance
0 commit comments