MCPcopy Index your code
hub / github.com/python/cpython / _format

Method _format

Lib/inspect.py:2777–2798  ·  view source on GitHub ↗
(self, *, quote_annotation_strings=True)

Source from the content-addressed store, hash-verified

2775 return self._format()
2776
2777 def _format(self, *, quote_annotation_strings=True):
2778 kind = self.kind
2779 formatted = self._name
2780
2781 # Add annotation and default value
2782 if self._annotation is not _empty:
2783 annotation = formatannotation(self._annotation,
2784 quote_annotation_strings=quote_annotation_strings)
2785 formatted = '{}: {}'.format(formatted, annotation)
2786
2787 if self._default is not _empty:
2788 if self._annotation is not _empty:
2789 formatted = '{} = {}'.format(formatted, repr(self._default))
2790 else:
2791 formatted = '{}={}'.format(formatted, repr(self._default))
2792
2793 if kind == _VAR_POSITIONAL:
2794 formatted = '*' + formatted
2795 elif kind == _VAR_KEYWORD:
2796 formatted = '**' + formatted
2797
2798 return formatted
2799
2800 __replace__ = replace
2801

Callers 2

__str__Method · 0.95
formatMethod · 0.45

Calls 2

formatannotationFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected