@@ -382,7 +382,7 @@ def _keep_object(name: str, filters: Sequence[tuple[Pattern, bool]]) -> bool:
382382
383383
384384def _construct_docstring_according_to_strategy (
385- name : str , obj : Object | Alias , strategy : DocstringInheritStrategy , merge_delimiter : str = "\n " ,
385+ name : str , obj : Class | Alias , strategy : DocstringInheritStrategy , merge_delimiter : str = "\n " ,
386386) -> Docstring | None :
387387 """Construct a docstring object according to the strategy.
388388
@@ -403,16 +403,18 @@ def _construct_docstring_according_to_strategy(
403403 for parent in list (obj .mro ()):
404404 # this traverses the parents in the order of the MRO, i.e. the first entry is the most direct parent
405405 if parent .members and name in parent .members and parent .members [name ].docstring :
406- return Docstring (value = parent .members [name ].docstring .value )
406+ return Docstring (value = parent .members [name ].docstring .value ) # type: ignore[union-attr]
407407 return None
408408
409409 if strategy == DocstringInheritStrategy .merge :
410410 docstrings = []
411- for parent in [* list (reversed (obj .mro ())), obj ]:
412- # Here we traverse the parents in the reverse order to build the docstring from the most general to the most specific annotations
413- # Addtionally, we include the object itself because we don't want to miss the docstring of the object itself if present
411+ traversal_order : list [Class | Alias ] = [* list (reversed (obj .mro ())), obj ]
412+ # Here we traverse the parents in the reverse order to build the docstring from the most general to the most specific annotations
413+ # Addtionally, we include the object itself because we don't want to miss the docstring of the object itself if present
414+
415+ for parent in traversal_order : # type: ignore[assignment]
414416 if parent .members and name in parent .members and parent .members [name ].docstring :
415- docstrings .append (parent .members [name ].docstring .value )
417+ docstrings .append (parent .members [name ].docstring .value ) # type: ignore[union-attr]
416418
417419 if not docstrings :
418420 # This guarantees that no empty docstring is constructed for a member that shouldn't have one at all
@@ -424,11 +426,11 @@ def _construct_docstring_according_to_strategy(
424426
425427
426428def do_optionally_inherit_docstrings (
427- objects : dict [str , Object | Alias ],
429+ objects : dict [str , Class | Alias ],
428430 * ,
429431 docstring_inherit_strategy : str = DocstringInheritStrategy .default .value ,
430432 docstring_merge_delimiter : str = "\n \n " ,
431- ) -> dict [str , Object | Alias ]:
433+ ) -> dict [str , Class | Alias ]:
432434 """Optionally inherit docstrings for members in the given .
433435
434436 Parameters:
0 commit comments