Path 1: 732 calls (0.49)

' ' (44) '\n✓ ' (36) ': ' (22) ' in ' (22) 'foo' (20) ', ' (20) ':' (19) 'Traceback ' (18) '(most recent call last)' (18) 'bar' (14)

None (732)

Text (732)

1def append(
2        self, text: Union["Text", str], style: Optional[Union[str, "Style"]] = None
3    ) -> "Text":
4        """Add text with an optional style.
5
6        Args:
7            text (Union[Text, str]): A str or Text to append.
8            style (str, optional): A style name. Defaults to None.
9
10        Returns:
11            Text: Returns self for chaining.
12        """
13
14        if not isinstance(text, (str, Text)):
15            raise TypeError("Only str or Text can be appended to Text")
16
17        if len(text):
18            if isinstance(text, str):
19                sanitized_text = strip_control_codes(text)
20                self._text.append(sanitized_text)
21                offset = len(self)
22                text_length = len(sanitized_text)
23                if style is not None:
24                    self._spans.append(Span(offset, offset + text_length, style))
25                self._length += text_length
26            elif isinstance(text, Text):
27                _Span = Span
28                if style is not None:
29                    raise ValueError(
30                        "style must not be set when appending Text instance"
31                    )
32                text_length = self._length
33                if text.style is not None:
34                    self._spans.append(
35                        _Span(text_length, text_length + len(text), text.style)
36                    )
37                self._text.append(text.plain)
38                self._spans.extend(
39                    _Span(start + text_length, end + text_length, style)
40                    for start, end, style in text._spans
41                )
42                self._length += len(text)
43        return self
            

Path 2: 611 calls (0.41)

' =' (101) ':' (23) 'test_logging.py' (16) 'ZeroDivisionError: ' (13) '──────────────────────────────' (12) '───────────────────────────────' (12) 'cl...

Style (183) 'inspect.equals' (99) 'inspect.attr' (98) '' (32) 'pygments.text' (23) 'pygments.number' (23) 'inspect.callable' (22) 'pygments.function' ...

Text (611)

1def append(
2        self, text: Union["Text", str], style: Optional[Union[str, "Style"]] = None
3    ) -> "Text":
4        """Add text with an optional style.
5
6        Args:
7            text (Union[Text, str]): A str or Text to append.
8            style (str, optional): A style name. Defaults to None.
9
10        Returns:
11            Text: Returns self for chaining.
12        """
13
14        if not isinstance(text, (str, Text)):
15            raise TypeError("Only str or Text can be appended to Text")
16
17        if len(text):
18            if isinstance(text, str):
19                sanitized_text = strip_control_codes(text)
20                self._text.append(sanitized_text)
21                offset = len(self)
22                text_length = len(sanitized_text)
23                if style is not None:
24                    self._spans.append(Span(offset, offset + text_length, style))
25                self._length += text_length
26            elif isinstance(text, Text):
27                _Span = Span
28                if style is not None:
29                    raise ValueError(
30                        "style must not be set when appending Text instance"
31                    )
32                text_length = self._length
33                if text.style is not None:
34                    self._spans.append(
35                        _Span(text_length, text_length + len(text), text.style)
36                    )
37                self._text.append(text.plain)
38                self._spans.extend(
39                    _Span(start + text_length, end + text_length, style)
40                    for start, end, style in text._spans
41                )
42                self._length += len(text)
43        return self
            

Path 3: 155 calls (0.1)

Text (155)

None (155)

Text (155)

1def append(
2        self, text: Union["Text", str], style: Optional[Union[str, "Style"]] = None
3    ) -> "Text":
4        """Add text with an optional style.
5
6        Args:
7            text (Union[Text, str]): A str or Text to append.
8            style (str, optional): A style name. Defaults to None.
9
10        Returns:
11            Text: Returns self for chaining.
12        """
13
14        if not isinstance(text, (str, Text)):
15            raise TypeError("Only str or Text can be appended to Text")
16
17        if len(text):
18            if isinstance(text, str):
19                sanitized_text = strip_control_codes(text)
20                self._text.append(sanitized_text)
21                offset = len(self)
22                text_length = len(sanitized_text)
23                if style is not None:
24                    self._spans.append(Span(offset, offset + text_length, style))
25                self._length += text_length
26            elif isinstance(text, Text):
27                _Span = Span
28                if style is not None:
29                    raise ValueError(
30                        "style must not be set when appending Text instance"
31                    )
32                text_length = self._length
33                if text.style is not None:
34                    self._spans.append(
35                        _Span(text_length, text_length + len(text), text.style)
36                    )
37                self._text.append(text.plain)
38                self._spans.extend(
39                    _Span(start + text_length, end + text_length, style)
40                    for start, end, style in text._spans
41                )
42                self._length += len(text)
43        return self
            

Path 4: 1 calls (0.0)

Text (1)

'bar' (1)

ValueError (1)

1def append(
2        self, text: Union["Text", str], style: Optional[Union[str, "Style"]] = None
3    ) -> "Text":
4        """Add text with an optional style.
5
6        Args:
7            text (Union[Text, str]): A str or Text to append.
8            style (str, optional): A style name. Defaults to None.
9
10        Returns:
11            Text: Returns self for chaining.
12        """
13
14        if not isinstance(text, (str, Text)):
15            raise TypeError("Only str or Text can be appended to Text")
16
17        if len(text):
18            if isinstance(text, str):
19                sanitized_text = strip_control_codes(text)
20                self._text.append(sanitized_text)
21                offset = len(self)
22                text_length = len(sanitized_text)
23                if style is not None:
24                    self._spans.append(Span(offset, offset + text_length, style))
25                self._length += text_length
26            elif isinstance(text, Text):
27                _Span = Span
28                if style is not None:
29                    raise ValueError(
30                        "style must not be set when appending Text instance"
31                    )
32                text_length = self._length
33                if text.style is not None:
34                    self._spans.append(
35                        _Span(text_length, text_length + len(text), text.style)
36                    )
37                self._text.append(text.plain)
38                self._spans.extend(
39                    _Span(start + text_length, end + text_length, style)
40                    for start, end, style in text._spans
41                )
42                self._length += len(text)
43        return self
            

Path 5: 1 calls (0.0)

1 (1)

None (1)

TypeError (1)

1def append(
2        self, text: Union["Text", str], style: Optional[Union[str, "Style"]] = None
3    ) -> "Text":
4        """Add text with an optional style.
5
6        Args:
7            text (Union[Text, str]): A str or Text to append.
8            style (str, optional): A style name. Defaults to None.
9
10        Returns:
11            Text: Returns self for chaining.
12        """
13
14        if not isinstance(text, (str, Text)):
15            raise TypeError("Only str or Text can be appended to Text")
16
17        if len(text):
18            if isinstance(text, str):
19                sanitized_text = strip_control_codes(text)
20                self._text.append(sanitized_text)
21                offset = len(self)
22                text_length = len(sanitized_text)
23                if style is not None:
24                    self._spans.append(Span(offset, offset + text_length, style))
25                self._length += text_length
26            elif isinstance(text, Text):
27                _Span = Span
28                if style is not None:
29                    raise ValueError(
30                        "style must not be set when appending Text instance"
31                    )
32                text_length = self._length
33                if text.style is not None:
34                    self._spans.append(
35                        _Span(text_length, text_length + len(text), text.style)
36                    )
37                self._text.append(text.plain)
38                self._spans.extend(
39                    _Span(start + text_length, end + text_length, style)
40                    for start, end, style in text._spans
41                )
42                self._length += len(text)
43        return self