resolved RESOLVED PASS · 22 tool calls · 115 s · Textualize/rich
proxy isatty Fixes https://github.com/Textualize/rich/issues/4041
| # | Tool | Arguments | Result |
|---|---|---|---|
| 1 | run_command | {
"command": "grep -rn \"isatty\" rich | head -20"
} | {"status": "ok", "stdout": "rich/console.py:969: isatty: Optional[Callable[[], bool]] = getattr(self.file, \"isatty\", None)\nrich/console.py:971: return False full{"status": "ok", "stdout": "rich/console.py:969: isatty: Optional[Callable[[], bool]] = getattr(self.file, \"isatty\", None)\nrich/console.py:971: return False if isatty is None else isatty()\nrich/console.py:973: # in some situation (at the end of a pytest run for example) isatty() can raise\nrich/_null_file.py:9: def isatty(self) -> bool:\nrich/progress.py:225: def isatty(self) -> bool:\nrich/progress.py:226: return self.handle.isatty()\n", "stderr": "", "exit_code": 0} |
| 2 | run_command | {
"command": "sed -n '960,980p' rich/console.py"
} | {"status": "ok", "stdout": " if tty_compatible == \"1\":\n return True\n\n # https://force-color.org/\n force_color = environ.get(\"FORCE_COLOR\")\n if force_cofull{"status": "ok", "stdout": " if tty_compatible == \"1\":\n return True\n\n # https://force-color.org/\n force_color = environ.get(\"FORCE_COLOR\")\n if force_color is not None:\n return force_color != \"\"\n\n # Any other value defaults to auto detect\n isatty: Optional[Callable[[], bool]] = getattr(self.file, \"isatty\", None)\n try:\n return False if isatty is None else isatty()\n except ValueError:\n # in some situation (at the end of a pytest run for example) isatty() can raise\n # ValueError: I/O operation on closed file\n # return False because we aren't in a terminal anymore\n return False\n\n @property\n def is_dumb_terminal(self) -> bool:\n \"\"\"Detect dumb terminal.\n", "stderr": "", "exit_code": 0} |
| 3 | run_command | {
"command": "grep -rn \"isatty\" rich/console.py"
} | {"status": "ok", "stdout": "rich/console.py:969: isatty: Optional[Callable[[], bool]] = getattr(self.file, \"isatty\", None)\nrich/console.py:971: return False full{"status": "ok", "stdout": "rich/console.py:969: isatty: Optional[Callable[[], bool]] = getattr(self.file, \"isatty\", None)\nrich/console.py:971: return False if isatty is None else isatty()\nrich/console.py:973: # in some situation (at the end of a pytest run for example) isatty() can raise\n", "stderr": "", "exit_code": 0} |
| 4 | run_command | {
"command": "grep -n \"def is_terminal\" rich/console.py"
} | {"status": "ok", "stdout": "931: def is_terminal(self) -> bool:\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "931: def is_terminal(self) -> bool:\n", "stderr": "", "exit_code": 0} |
| 5 | run_command | {
"command": "sed -n '931,975p' rich/console.py"
} | {"status": "ok", "stdout": " def is_terminal(self) -> bool:\n \"\"\"Check if the console is writing to a terminal.\n\n Returns:\n bool: True if the console writfull{"status": "ok", "stdout": " def is_terminal(self) -> bool:\n \"\"\"Check if the console is writing to a terminal.\n\n Returns:\n bool: True if the console writing to a device capable of\n understanding escape sequences, otherwise False.\n \"\"\"\n # If dev has explicitly set this value, return it\n if self._force_terminal is not None:\n return self._force_terminal\n\n # Fudge for Idle\n if hasattr(sys.stdin, \"__module__\") and sys.stdin.__module__.startswith(\n \"idlelib\"\n ):\n # Return False for Idle which claims to be a tty but can't handle ansi codes\n return False\n\n if self.is_jupyter:\n # return False for Jupyter, which may have FORCE_COLOR set\n return False\n\n environ = self._environ\n\n tty_compatible = environ.get(\"TTY_COMPATIBLE\", \"\")\n # 0 indicates device is not tty compatible\n if tty_compatible == \"0\":\n return False\n # 1 indicates device is tty compatible\n if tty_compatible == \"1\":\n return True\n\n # https://force-color.org/\n force_color = environ.get(\"FORCE_COLOR\")\n if force_color is not None:\n return force_color != \"\"\n\n # Any other value defaults to auto detect\n isatty: Optional[Callable[[], bool]] = getattr(self.file, \"isatty\", None)\n try:\n return False if isatty is None else isatty()\n except ValueError:\n # in some situation (at the end of a pytest run for example) isatty() can raise\n # ValueError: I/O operation on closed file\n # return False because we aren't in a terminal anymore\n", "stderr": "", "exit_code": 0} |
| 6 | run_command | {
"command": "grep -rn \"isatty\" rich | grep \"def isatty\""
} | {"status": "ok", "stdout": "rich/_null_file.py:9: def isatty(self) -> bool:\nrich/progress.py:225: def isatty(self) -> bool:\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "rich/_null_file.py:9: def isatty(self) -> bool:\nrich/progress.py:225: def isatty(self) -> bool:\n", "stderr": "", "exit_code": 0} |
| 7 | run_command | {
"command": "grep -n \"def __init__\" rich/console.py"
} | {"status": "ok", "stdout": "283: def __init__(self, count: int = 1) -> None:\n295: def __init__(self, lines: List[List[Segment]], x: int, y: int) -> None:\n318:full{"status": "ok", "stdout": "283: def __init__(self, count: int = 1) -> None:\n295: def __init__(self, lines: List[List[Segment]], x: int, y: int) -> None:\n318: def __init__(self, console: \"Console\") -> None:\n346: def __init__(self, console: \"Console\", theme: Theme, inherit: bool = True) -> None:\n367: def __init__(\n406: def __init__(\n458: def __init__(self, *renderables: \"RenderableType\", fit: bool = True) -> None:\n619: def __init__(\n", "stderr": "", "exit_code": 0} |
| 8 | run_command | {
"command": "sed -n '619,650p' rich/console.py"
} | {"status": "ok", "stdout": " def __init__(\n self,\n *,\n color_system: Optional[\n Literal[\"auto\", \"standard\", \"256\", \"truecolor\", \"windows\"]\n ] = \full{"status": "ok", "stdout": " def __init__(\n self,\n *,\n color_system: Optional[\n Literal[\"auto\", \"standard\", \"256\", \"truecolor\", \"windows\"]\n ] = \"auto\",\n force_terminal: Optional[bool] = None,\n force_jupyter: Optional[bool] = None,\n force_interactive: Optional[bool] = None,\n soft_wrap: bool = False,\n theme: Optional[Theme] = None,\n stderr: bool = False,\n file: Optional[IO[str]] = None,\n quiet: bool = False,\n width: Optional[int] = None,\n height: Optional[int] = None,\n style: Optional[StyleType] = None,\n no_color: Optional[bool] = None,\n tab_size: int = 8,\n record: bool = False,\n markup: bool = True,\n emoji: bool = True,\n emoji_variant: Optional[EmojiVariant] = None,\n highlight: bool = True,\n log_time: bool = True,\n log_path: bool = True,\n log_time_format: Union[str, FormatTimeCallable] = \"[%X]\",\n highlighter: Optional[\"HighlighterType\"] = ReprHighlighter(),\n legacy_windows: Optional[bool] = None,\n safe_box: bool = True,\n get_datetime: Optional[Callable[[], datetime]] = None,\n get_time: Optional[Callable[[], float]] = None,\n", "stderr": "", "exit_code": 0} |
| 9 | run_command | {
"command": "sed -n '650,700p' rich/console.py"
} | {"status": "ok", "stdout": " get_time: Optional[Callable[[], float]] = None,\n _environ: Optional[Mapping[str, str]] = None,\n ):\n # Copy of os.environ allows full{"status": "ok", "stdout": " get_time: Optional[Callable[[], float]] = None,\n _environ: Optional[Mapping[str, str]] = None,\n ):\n # Copy of os.environ allows us to replace it for testing\n if _environ is not None:\n self._environ = _environ\n\n self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter\n if self.is_jupyter:\n if width is None:\n jupyter_columns = self._environ.get(\"JUPYTER_COLUMNS\")\n if jupyter_columns is not None and jupyter_columns.isdigit():\n width = int(jupyter_columns)\n else:\n width = JUPYTER_DEFAULT_COLUMNS\n if height is None:\n jupyter_lines = self._environ.get(\"JUPYTER_LINES\")\n if jupyter_lines is not None and jupyter_lines.isdigit():\n height = int(jupyter_lines)\n else:\n height = JUPYTER_DEFAULT_LINES\n\n self.tab_size = tab_size\n self.record = record\n self._markup = markup\n self._emoji = emoji\n self._emoji_variant: Optional[EmojiVariant] = emoji_variant\n self._highlight = highlight\n self.legacy_windows: bool = (\n (detect_legacy_windows() and not self.is_jupyter)\n if legacy_windows is None\n else legacy_windows\n )\n\n if width is None:\n columns = self._environ.get(\"COLUMNS\")\n if columns is not None and columns.isdigit():\n width = int(columns) - self.legacy_windows\n if height is None:\n lines = self._environ.get(\"LINES\")\n if lines is not None and lines.isdigit():\n height = int(lines)\n\n self.soft_wrap = soft_wrap\n self._width = width\n self._height = height\n\n self._color_system: Optional[ColorSystem]\n\n self._force_terminal = None\n |
| 10 | run_command | {
"command": "sed -n '700,750p' rich/console.py"
} | {"status": "ok", "stdout": " if force_terminal is not None:\n self._force_terminal = force_terminal\n\n self._file = file\n self.quiet = quiet\n self.stderr = sfull{"status": "ok", "stdout": " if force_terminal is not None:\n self._force_terminal = force_terminal\n\n self._file = file\n self.quiet = quiet\n self.stderr = stderr\n\n if color_system is None:\n self._color_system = None\n elif color_system == \"auto\":\n self._color_system = self._detect_color_system()\n else:\n self._color_system = COLOR_SYSTEMS[color_system]\n\n self._lock = threading.RLock()\n self._log_render = LogRender(\n show_time=log_time,\n show_path=log_path,\n time_format=log_time_format,\n )\n self.highlighter: HighlighterType = highlighter or _null_highlighter\n self.safe_box = safe_box\n self.get_datetime = get_datetime or datetime.now\n self.get_time = get_time or monotonic\n self.style = style\n self.no_color = (\n no_color\n if no_color is not None\n else self._environ.get(\"NO_COLOR\", \"\") != \"\"\n )\n if force_interactive is None:\n tty_interactive = self._environ.get(\"TTY_INTERACTIVE\", None)\n if tty_interactive is not None:\n if tty_interactive == \"0\":\n force_interactive = False\n elif tty_interactive == \"1\":\n force_interactive = True\n\n self.is_interactive = (\n (self.is_terminal and not self.is_dumb_terminal)\n if force_interactive is None\n else force_interactive\n )\n\n self._record_buffer_lock = threading.RLock()\n self._thread_locals = ConsoleThreadLocals(\n theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)\n )\n self._record_buffer: List[Segment] = []\n self._render_hooks: List[RenderHook] = []\n self._live_stack: List[Live] = []\n", "stderr": "", "exit_code": 0} |
| 11 | run_command | {
"command": "sed -n '730,750p' rich/console.py"
} | {"status": "ok", "stdout": " if force_interactive is None:\n tty_interactive = self._environ.get(\"TTY_INTERACTIVE\", None)\n if tty_interactive is not None:\n full{"status": "ok", "stdout": " if force_interactive is None:\n tty_interactive = self._environ.get(\"TTY_INTERACTIVE\", None)\n if tty_interactive is not None:\n if tty_interactive == \"0\":\n force_interactive = False\n elif tty_interactive == \"1\":\n force_interactive = True\n\n self.is_interactive = (\n (self.is_terminal and not self.is_dumb_terminal)\n if force_interactive is None\n else force_interactive\n )\n\n self._record_buffer_lock = threading.RLock()\n self._thread_locals = ConsoleThreadLocals(\n theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)\n )\n self._record_buffer: List[Segment] = []\n self._render_hooks: List[RenderHook] = []\n self._live_stack: List[Live] = []\n", "stderr": "", "exit_code": 0} |
| 12 | run_command | {
"command": "grep -n \"property\" rich/console.py | grep \"file\""
} | {"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}full{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}} |
| 13 | run_command | {
"command": "grep -n \"def file\" rich/console.py"
} | {"status": "ok", "stdout": "757: def file(self) -> IO[str]:\n766: def file(self, new_file: IO[str]) -> None:\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "757: def file(self) -> IO[str]:\n766: def file(self, new_file: IO[str]) -> None:\n", "stderr": "", "exit_code": 0} |
| 14 | run_command | {
"command": "sed -n '757,770p' rich/console.py"
} | {"status": "ok", "stdout": " def file(self) -> IO[str]:\n \"\"\"Get the file object to write to.\"\"\"\n file = self._file or (sys.stderr if self.stderr else syfull{"status": "ok", "stdout": " def file(self) -> IO[str]:\n \"\"\"Get the file object to write to.\"\"\"\n file = self._file or (sys.stderr if self.stderr else sys.stdout)\n file = getattr(file, \"rich_proxied_file\", file)\n if file is None:\n file = NULL_FILE\n return file\n\n @file.setter\n def file(self, new_file: IO[str]) -> None:\n \"\"\"Set a new file object.\"\"\"\n self._file = new_file\n\n @property\n", "stderr": "", "exit_code": 0} |
| 15 | run_command | {
"command": "grep -rn \"rich_proxied_file\" rich"
} | {"status": "ok", "stdout": "rich/console.py:760: file = getattr(file, \"rich_proxied_file\", file)\nrich/file_proxy.py:21: def rich_proxied_file(self) -> IO[strfull{"status": "ok", "stdout": "rich/console.py:760: file = getattr(file, \"rich_proxied_file\", file)\nrich/file_proxy.py:21: def rich_proxied_file(self) -> IO[str]:\n", "stderr": "", "exit_code": 0} |
| 16 | run_command | {
"command": "cat rich/file_proxy.py"
} | {"status": "ok", "stdout": "import io\nfrom typing import IO, TYPE_CHECKING, Any, List\n\nfrom .ansi import AnsiDecoder\nfrom .text import Text\n\nif TYPE_CHECKfull{"status": "ok", "stdout": "import io\nfrom typing import IO, TYPE_CHECKING, Any, List\n\nfrom .ansi import AnsiDecoder\nfrom .text import Text\n\nif TYPE_CHECKING:\n from .console import Console\n\n\nclass FileProxy(io.TextIOBase):\n \"\"\"Wraps a file (e.g. sys.stdout) and redirects writes to a console.\"\"\"\n\n def __init__(self, console: \"Console\", file: IO[str]) -> None:\n self.__console = console\n self.__file = file\n self.__buffer: List[str] = []\n self.__ansi_decoder = AnsiDecoder()\n\n @property\n def rich_proxied_file(self) -> IO[str]:\n \"\"\"Get proxied file.\"\"\"\n return self.__file\n\n def __getattr__(self, name: str) -> Any:\n return getattr(self.__file, name)\n\n def write(self, text: str) -> int:\n if not isinstance(text, str):\n raise TypeError(f\"write() argument must be str, not {type(text).__name__}\")\n buffer = self.__buffer\n lines: List[str] = []\n while text:\n line, new_line, text = text.partition(\"\\n\")\n if new_line:\n lines.append(\"\".join(buffer) + line)\n buffer.clear()\n else:\n buffer.append(line)\n break\n if lines:\n console = self.__console\n with console:\n output = Text(\"\\n\").join(\n self.__ansi_decoder.decode_line(line) for line in lines\n )\n console.print(output)\n return len(text)\n\n def flush(self) -> None:\n output = \"\".join(self.__buffer)\n if output:\n self.__console.print(output)\n del self.__buffer[:]\n\n def fileno(self) -> int:\n return self.__file.fileno()\n", "stderr": "", "exit_code": 0} |
| 17 | run_command | {
"command": "grep -n \"def isatty\" rich/file_proxy.py"
} | {"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}full{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}} |
| 18 | run_command | {
"command": "cat -n rich/file_proxy.py"
} | {"status": "ok", "stdout": " 1\timport io\n 2\tfrom typing import IO, TYPE_CHECKING, Any, List\n 3\t\n 4\tfrom .ansi import AnsiDecoder\n 5\tfrom .text import Tfull{"status": "ok", "stdout": " 1\timport io\n 2\tfrom typing import IO, TYPE_CHECKING, Any, List\n 3\t\n 4\tfrom .ansi import AnsiDecoder\n 5\tfrom .text import Text\n 6\t\n 7\tif TYPE_CHECKING:\n 8\t from .console import Console\n 9\t\n 10\t\n 11\tclass FileProxy(io.TextIOBase):\n 12\t \"\"\"Wraps a file (e.g. sys.stdout) and redirects writes to a console.\"\"\"\n 13\t\n 14\t def __init__(self, console: \"Console\", file: IO[str]) -> None:\n 15\t self.__console = console\n 16\t self.__file = file\n 17\t self.__buffer: List[str] = []\n 18\t self.__ansi_decoder = AnsiDecoder()\n 19\t\n 20\t @property\n 21\t def rich_proxied_file(self) -> IO[str]:\n 22\t \"\"\"Get proxied file.\"\"\"\n 23\t return self.__file\n 24\t\n 25\t def __getattr__(self, name: str) -> Any:\n 26\t return getattr(self.__file, name)\n 27\t\n 28\t def write(self, text: str) -> int:\n 29\t if not isinstance(text, str):\n 30\t raise TypeError(f\"write() argument must be str, not {type(text).__name__}\")\n 31\t buffer = self.__buffer\n 32\t lines: List[str] = []\n 33\t while text:\n 34\t line, new_line, text = text.partition(\"\\n\")\n 35\t if new_line:\n 36\t lines.append(\"\".join(buffer) + line)\n 37\t buffer.clear()\n 38\t else:\n 39\t buffer.append(line)\n 40\t break\n 41\t if lines:\n 42\t console = self.__console\n 43\t with console:\n 44\t output = Text(\"\\n\").join(\n 45\t self.__ansi_decoder.decode_line(line) for line in lines\n 46\t )\n 47\t console.print(output)\n 48\t return len(text)\n 49\t\n 50\t def flush(self) -> None:\n 51\t |
| 19 | run_command | {
"command": "python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"rich/file_proxy.py\")\ns = p.read_text()\nold = \"\"\" def fileno(self) -> int:\n return self.__file.fileno()\"\"\"\nnew = \"\"\" def fileno(self) -> int:\n return self.__file.fileno()\n\n def isatty(self) -> bool:\n return self.__file.isatty()\"\"\"\nassert s.count(old) == 1\nt = s.replace(old, new)\np.write_text(t)\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 20 | run_command | {
"command": "cat rich/file_proxy.py"
} | {"status": "ok", "stdout": "import io\nfrom typing import IO, TYPE_CHECKING, Any, List\n\nfrom .ansi import AnsiDecoder\nfrom .text import Text\n\nif TYPE_CHECKfull{"status": "ok", "stdout": "import io\nfrom typing import IO, TYPE_CHECKING, Any, List\n\nfrom .ansi import AnsiDecoder\nfrom .text import Text\n\nif TYPE_CHECKING:\n from .console import Console\n\n\nclass FileProxy(io.TextIOBase):\n \"\"\"Wraps a file (e.g. sys.stdout) and redirects writes to a console.\"\"\"\n\n def __init__(self, console: \"Console\", file: IO[str]) -> None:\n self.__console = console\n self.__file = file\n self.__buffer: List[str] = []\n self.__ansi_decoder = AnsiDecoder()\n\n @property\n def rich_proxied_file(self) -> IO[str]:\n \"\"\"Get proxied file.\"\"\"\n return self.__file\n\n def __getattr__(self, name: str) -> Any:\n return getattr(self.__file, name)\n\n def write(self, text: str) -> int:\n if not isinstance(text, str):\n raise TypeError(f\"write() argument must be str, not {type(text).__name__}\")\n buffer = self.__buffer\n lines: List[str] = []\n while text:\n line, new_line, text = text.partition(\"\\n\")\n if new_line:\n lines.append(\"\".join(buffer) + line)\n buffer.clear()\n else:\n buffer.append(line)\n break\n if lines:\n console = self.__console\n with console:\n output = Text(\"\\n\").join(\n self.__ansi_decoder.decode_line(line) for line in lines\n )\n console.print(output)\n return len(text)\n\n def flush(self) -> None:\n output = \"\".join(self.__buffer)\n if output:\n self.__console.print(output)\n del self.__buffer[:]\n\n def fileno(self) -> int:\n return self.__file.fileno()\n\n def isatty(self) -> bool:\n return self.__file.isatty()\n", "stderr": "", "exit_code": 0} |
| 21 | run_command | {
"command": "git diff"
} | {"status": "ok", "stdout": "diff --git a/rich/file_proxy.py b/rich/file_proxy.py\nindex 4b0b0da6..e32523bd 100644\n--- a/rich/file_proxy.py\n+++ b/rich/file_profull{"status": "ok", "stdout": "diff --git a/rich/file_proxy.py b/rich/file_proxy.py\nindex 4b0b0da6..e32523bd 100644\n--- a/rich/file_proxy.py\n+++ b/rich/file_proxy.py\n@@ -55,3 +55,6 @@ class FileProxy(io.TextIOBase):\n \n def fileno(self) -> int:\n return self.__file.fileno()\n+\n+ def isatty(self) -> bool:\n+ return self.__file.isatty()\n", "stderr": "", "exit_code": 0} |
| 22 | run_command | {
"command": "submit_patch"
} | {"status": "error", "error_type": "CommandError", "error_message": "/bin/bash: submit_patch: command not found\n", "details": {"stdout": "", "stderr": "/bin/basfull{"status": "error", "error_type": "CommandError", "error_message": "/bin/bash: submit_patch: command not found\n", "details": {"stdout": "", "stderr": "/bin/bash: submit_patch: command not found\n", "exit_code": 127}} |
| 23 | submit_patch | {} | {"status": "ok", "patch_size": 324, "files_changed": 1}full{"status": "ok", "patch_size": 324, "files_changed": 1} |
diff --git a/rich/file_proxy.py b/rich/file_proxy.py
index 4b0b0da6..e32523bd 100644
--- a/rich/file_proxy.py
+++ b/rich/file_proxy.py
@@ -55,3 +55,6 @@ class FileProxy(io.TextIOBase):
def fileno(self) -> int:
return self.__file.fileno()
+
+ def isatty(self) -> bool:
+ return self.__file.isatty()
.... [100%] 4 passed in 0.06s