Path 1: 2 calls (0.5)

bytes (2)

TypeError (2)

1def write(self, text: str) -> int:
2        if not isinstance(text, str):
3            raise TypeError(f"write() argument must be str, not {type(text).__name__}")
4        buffer = self.__buffer
5        lines: List[str] = []
6        while text:
7            line, new_line, text = text.partition("\n")
8            if new_line:
9                lines.append("".join(buffer) + line)
10                del buffer[:]
11            else:
12                buffer.append(line)
13                break
14        if lines:
15            console = self.__console
16            with console:
17                output = Text("\n").join(
18                    self.__ansi_decoder.decode_line(line) for line in lines
19                )
20                console.print(output)
21        return len(text)
            

Path 2: 1 calls (0.25)

'foo' (1)

0 (1)

1def write(self, text: str) -> int:
2        if not isinstance(text, str):
3            raise TypeError(f"write() argument must be str, not {type(text).__name__}")
4        buffer = self.__buffer
5        lines: List[str] = []
6        while text:
7            line, new_line, text = text.partition("\n")
8            if new_line:
9                lines.append("".join(buffer) + line)
10                del buffer[:]
11            else:
12                buffer.append(line)
13                break
14        if lines:
15            console = self.__console
16            with console:
17                output = Text("\n").join(
18                    self.__ansi_decoder.decode_line(line) for line in lines
19                )
20                console.print(output)
21        return len(text)
            

Path 3: 1 calls (0.25)

'-\n-' (1)

0 (1)

1def write(self, text: str) -> int:
2        if not isinstance(text, str):
3            raise TypeError(f"write() argument must be str, not {type(text).__name__}")
4        buffer = self.__buffer
5        lines: List[str] = []
6        while text:
7            line, new_line, text = text.partition("\n")
8            if new_line:
9                lines.append("".join(buffer) + line)
10                del buffer[:]
11            else:
12                buffer.append(line)
13                break
14        if lines:
15            console = self.__console
16            with console:
17                output = Text("\n").join(
18                    self.__ansi_decoder.decode_line(line) for line in lines
19                )
20                console.print(output)
21        return len(text)