parameters: (ob)
return_statement: return argspec or _default_callable_argspec
docstring: Return a string describing the signature of a callable object, or ''.
  
      For Python-coded functions and methods, the first line is introspected.
      Delete 'self' parameter for classes (.__init__) and bound methods.
      The next lines are the first lines of the doc string up to the first
      empty line or _MAX_LINES.    For builtins, this typically includes
      the arguments in addition to the return value.
docstring_summary: Return a string describing the signature of a callable object, or ''.
docstring_tokens: Return a string describing the signature of a callable object or .
function: def get_argspec(ob):
      '''Return a string describing the signature of a callable object, or ''.
  
      For Python-coded functions and methods, the first line is introspected.
      Delete 'self' parameter for classes (.__init__) and bound methods.
      The next lines are the first lines of the doc string up to the first
      empty line or _MAX_LINES.    For builtins, this typically includes
      the arguments in addition to the return value.
      '''
      # Determine function object fob to inspect.
      try:
          ob_call = ob.__call__
      except BaseException:  # Buggy user object could raise anything.
          return ''  # No popup for non-callables.
      fob = ob_call if isinstance(ob_call, types.MethodType) else ob
  
      # Initialize argspec and wrap it to get lines.
      try:
          argspec = str(inspect.signature(fob))
      except Exception as err:
          msg = str(err)
          if msg.startswith(_invalid_method):
              return _invalid_method
          else:
              argspec = ''
  
      if '/' in argspec and len(argspec) < _MAX_COLS - len(_argument_positional):
          # Add explanation TODO remove after 3.7, before 3.9.
          argspec += _argument_positional
      if isinstance(fob, type) and argspec == '()':
          # If fob has no argument, use default callable argspec.
          argspec = _default_callable_argspec
  
      lines = (textwrap.wrap(argspec, _MAX_COLS, subsequent_indent=_INDENT)
               if len(argspec) > _MAX_COLS else [argspec] if argspec else [])
  
      # Augment lines from docstring, if any, and join to get argspec.
      if isinstance(ob_call, types.MethodType):
          doc = ob_call.__doc__
      else:
          doc = getattr(ob, "__doc__", "")
      if doc:
          for line in doc.split('\n', _MAX_LINES)[:_MAX_LINES]:
              line = line.strip()
              if not line:
                  break
              if len(line) > _MAX_COLS:
                  line = line[: _MAX_COLS - 3] + '...'
              lines.append(line)
      argspec = '\n'.join(lines)
  
      return argspec or _default_callable_argspec
function_tokens: def get_argspec ( ob ) : # Determine function object fob to inspect. try : ob_call = ob . __call__ except BaseException : # Buggy user object could raise anything. return '' # No popup for non-callables. fob = ob_call if isinstance ( ob_call , types . MethodType ) else ob # Initialize argspec and wrap it to get lines. try : argspec = str ( inspect . signature ( fob ) ) except Exception as err : msg = str ( err ) if msg . startswith ( _invalid_method ) : return _invalid_method else : argspec = '' if '/' in argspec and len ( argspec ) < _MAX_COLS - len ( _argument_positional ) : # Add explanation TODO remove after 3.7, before 3.9. argspec += _argument_positional if isinstance ( fob , type ) and argspec == '()' : # If fob has no argument, use default callable argspec. argspec = _default_callable_argspec lines = ( textwrap . wrap ( argspec , _MAX_COLS , subsequent_indent = _INDENT ) if len ( argspec ) > _MAX_COLS else [ argspec ] if argspec else [ ] ) # Augment lines from docstring, if any, and join to get argspec. if isinstance ( ob_call , types . MethodType ) : doc = ob_call . __doc__ else : doc = getattr ( ob , "__doc__" , "" ) if doc : for line in doc . split ( '\n' , _MAX_LINES ) [ : _MAX_LINES ] : line = line . strip ( ) if not line : break if len ( line ) > _MAX_COLS : line = line [ : _MAX_COLS - 3 ] + '...' lines . append ( line ) argspec = '\n' . join ( lines ) return argspec or _default_callable_argspec