@@ -355,11 +355,11 @@ def build(func: FunctionType, node_class: t.Type['ProcessNode']) -> t.Type['Func
355355 """
356356 if (
357357 not issubclass (node_class , ProcessNode ) # type: ignore[redundant-expr]
358- or not issubclass (node_class , FunctionCalculationMixin ) # type: ignore[unreachable]
358+ or not issubclass (node_class , FunctionCalculationMixin )
359359 ):
360360 raise TypeError ('the node_class should be a sub class of `ProcessNode` and `FunctionCalculationMixin`' )
361361
362- signature = inspect .signature (func ) # type: ignore[unreachable]
362+ signature = inspect .signature (func )
363363
364364 args : list [str ] = []
365365 var_positional : str | None = None
@@ -373,17 +373,21 @@ def build(func: FunctionType, node_class: t.Type['ProcessNode']) -> t.Type['Func
373373 LOGGER .warning (f'function `{ func .__name__ } ` has invalid type hints: { exception } ' )
374374 annotations = {}
375375
376- try :
377- parsed_docstring = docstring_parser .parse (func .__doc__ )
378- except Exception as exception :
379- LOGGER .warning (f'function `{ func .__name__ } ` has a docstring that could not be parsed: { exception } ' )
380- param_help_string = {}
376+ if func .__doc__ is None :
377+ param_help_string : dict [str , str | None ] = {}
381378 namespace_help_string = None
382379 else :
383- param_help_string = {param .arg_name : param .description for param in parsed_docstring .params }
384- namespace_help_string = parsed_docstring .short_description if parsed_docstring .short_description else ''
385- if parsed_docstring .long_description is not None :
386- namespace_help_string += f'\n \n { parsed_docstring .long_description } '
380+ try :
381+ parsed_docstring = docstring_parser .parse (func .__doc__ )
382+ except Exception as exception :
383+ LOGGER .warning (f'function `{ func .__name__ } ` has a docstring that could not be parsed: { exception } ' )
384+ param_help_string = {}
385+ namespace_help_string = None
386+ else :
387+ param_help_string = {param .arg_name : param .description for param in parsed_docstring .params }
388+ namespace_help_string = parsed_docstring .short_description if parsed_docstring .short_description else ''
389+ if parsed_docstring .long_description is not None :
390+ namespace_help_string += f'\n \n { parsed_docstring .long_description } '
387391
388392 for key , parameter in signature .parameters .items ():
389393 if parameter .kind in [parameter .POSITIONAL_ONLY , parameter .POSITIONAL_OR_KEYWORD , parameter .KEYWORD_ONLY ]:
@@ -435,7 +439,7 @@ def define(cls, spec):
435439 def indirect_default (value = default ):
436440 return to_aiida_type (value )
437441 else :
438- indirect_default = default
442+ indirect_default = default # type: ignore[assignment]
439443
440444 spec .input (
441445 parameter .name ,
0 commit comments