← eval_submission_analyzer

rich_4070

failed CONTEXT LOOP UNSUBMITTED agent_error · 37 tool calls · 134 s · Textualize/rich

Task input

perf: reduce Console and RichHandler import time by deferring unused imports

## E2E Results

| Import | master | This PR | Speedup |
|---|---|---|---|
| `from rich.console import Console` | 78.1ms | 52.2ms | **1.50x faster** |
| `from rich.logging import RichHandler` | 99.4ms | 56.9ms | **1.75x faster** |
| `import rich` | 18.2ms | 18.3ms | (already lean) |

## Summary

Defer module-level imports that are only needed in specific code paths, move annotation-only imports to `TYPE_CHECKING`, and remove dead code:

| File | Change | Savings |
|---|---|---|
| `logging.py` | Defer `Traceback` to `emit()` (only when `rich_tracebacks=True`) | ~20ms |
| `logging.py` | `from __future__ import annotations` + `TYPE_CHECKING` for `Console`, `ConsoleRenderable`, `Highlighter`, `FormatTimeCallable` | ~6ms |
| `logging.py` | Replace `pathlib.Path` → `os.path.basename` (also a minor runtime win) | ~4-5ms |
| `console.py` | Eliminate `import inspect`; replace `isclass` → `isinstance(x, type)`, `currentframe` → `sys._getframe` | ~10ms |
| `console.py` | Defer `pretty` to `Console.print()` | ~3-5ms |
| `console.py` | Defer `scope` to `Console.log()` (only when `log_locals=True`) | ~3-5ms |
| `console.py` | Defer `getpass` to `Console.input()` (only when `password=True`) | ~2ms |
| `console.py` | Defer `html.escape` and `zlib` to export methods | ~2.3ms |
| `console.py` | Remove dead `_svg_hash` function (unused since 113997ac, fixes latent NameError) | cleanup |
| `segment.py` | Remove dead `logging` import (`getLogger` assigned but never used) | ~2-3ms |
| `theme.py` | Defer `configparser` to `Theme.from_file()` | ~1.5ms |
| `syntax.py` | Move `Console`, `ConsoleOptions`, `JustifyMethod`, `RenderResult` to `TYPE_CHECKING` | eliminates console.py from syntax import chain |
| `protocol.py` | Replace `from inspect import isclass` → `isinstance(x, type)` | prepares for dataclasses removal |
| `repr.py` | Defer `import inspect` to `auto_rich_repr()` | prepares for dataclasses removal |

All deferred imports are still available at runtime — they're loaded when the code path that needs them is actually hit. The `TYPE_CHECKING` imports are annotation-only and never needed at runtime (files use `from __future__ import annotations`).

## Benchmarks

Environment: Standard_D2s_v5 (non-burstable), CPython 3.13.13, hyperfine --min-runs 30

### Per-module breakdown (this PR)

| Module | Time |
|---|---|
| `import rich` | 18.2ms |
| `Console` | 52.5ms |
| `RichHandler` | 56.4ms |
| `Syntax` | 64.7ms |
| `Traceback` | 92.5ms |
| `Markdown` | 103.0ms |

## Motivation

pip vendors Rich, and `Console`/`RichHandler` are imported on every `pip` invocation. These savings directly improve startup time for pip and every other tool that imports Rich.

## Testing

- `pytest tests/` — 952 passed, 25 skipped
- `mypy -p rich --no-incremental` — no issues
- `black --check` — passes

## Disclosure

This PR was developed with AI assistance (codeflash-agent). Benchmarked in a controlled environment (dedicated non-burstable Azure VM). All tests verified across multiple Python implementations.

Tool calls (37)

#ToolArgumentsResult
1run_command
{
 "command": "ls -R rich/"
}
{"status": "ok", "stdout": "rich/:\n__init__.py\n__main__.py\n_emoji_codes.py\n_emoji_replace.py\n_export_format.py\n_extension.py\n_fileno.py\n_inspect.py\n_lo
full
{"status": "ok", "stdout": "rich/:\n__init__.py\n__main__.py\n_emoji_codes.py\n_emoji_replace.py\n_export_format.py\n_extension.py\n_fileno.py\n_inspect.py\n_log_render.py\n_loop.py\n_null_file.py\n_palettes.py\n_pick.py\n_ratio.py\n_spinners.py\n_stack.py\n_timer.py\n_unicode_data\n_win32_console.py\n_windows.py\n_windows_renderer.py\n_wrap.py\nabc.py\nalign.py\nansi.py\nbar.py\nbox.py\ncells.py\ncolor.py\ncolor_triplet.py\ncolumns.py\nconsole.py\nconstrain.py\ncontainers.py\ncontrol.py\ndefault_styles.py\ndiagnose.py\nemoji.py\nerrors.py\nfile_proxy.py\nfilesize.py\nhighlighter.py\njson.py\njupyter.py\nlayout.py\nlive.py\nlive_render.py\nlogging.py\nmarkdown.py\nmarkup.py\nmeasure.py\npadding.py\npager.py\npalette.py\npanel.py\npretty.py\nprogress.py\nprogress_bar.py\nprompt.py\nprotocol.py\npy.typed\nregion.py\nrepr.py\nrule.py\nscope.py\nscreen.py\nsegment.py\nspinner.py\nstatus.py\nstyle.py\nstyled.py\nsyntax.py\ntable.py\nterminal_theme.py\ntext.py\ntheme.py\nthemes.py\ntraceback.py\ntree.py\n\nrich/_unicode_data:\n__init__.py\n_versions.py\nunicode10-0-0.py\nunicode11-0-0.py\nunicode12-0-0.py\nunicode12-1-0.py\nunicode13-0-0.py\nunicode14-0-0.py\nunicode15-0-0.py\nunicode15-1-0.py\nunicode16-0-0.py\nunicode17-0-0.py\nunicode4-1-0.py\nunicode5-0-0.py\nunicode5-1-0.py\nunicode5-2-0.py\nunicode6-0-0.py\nunicode6-1-0.py\nunicode6-2-0.py\nunicode6-3-0.py\nunicode7-0-0.py\nunicode8-0-0.py\nunicode9-0-0.py\n", "exit_code": 0}
2-3 ×2read_file
{
 "filepath": "rich/logging.py"
}
{"status": "ok", "filepath": "rich/logging.py", "content": "import logging\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib
full
{"status": "ok", "filepath": "rich/logging.py", "content": "import logging\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib import Path\nfrom types import ModuleType\nfrom typing import ClassVar, Iterable, List, Optional, Type, Union\n\nfrom rich._null_file import NullFile\n\nfrom . import get_console\nfrom ._log_render import FormatTimeCallable, LogRender\nfrom .console import Console, ConsoleRenderable\nfrom .highlighter import Highlighter, ReprHighlighter\nfrom .text import Text\nfrom .traceback import Traceback\n\n\nclass RichHandler(Handler):\n    \"\"\"A logging handler that renders output with Rich. The time / level / message and file are displayed in columns.\n    The level is color coded, and the message is syntax highlighted.\n\n    Note:\n        Be careful when enabling console markup in log messages if you have configured logging for libraries not\n        under your control. If a dependency writes messages containing square brackets, it may not produce the intended output.\n\n    Args:\n        level (Union[int, str], optional): Log level. Defaults to logging.NOTSET.\n        console (:class:`~rich.console.Console`, optional): Optional console instance to write logs.\n            Default will use a global console instance writing to stdout.\n        show_time (bool, optional): Show a column for the time. Defaults to True.\n        omit_repeated_times (bool, optional): Omit repetition of the same time. Defaults to True.\n        show_level (bool, optional): Show a column for the level. Defaults to True.\n        show_path (bool, optional): Show the path to the original log call. Defaults to True.\n        enable_link_path (bool, optional): Enable terminal link of path column to file. Defaults to True.\n        highlighter (Highlighter, optional): Highlighter to style log messages, or None to use ReprHighlighter. Defaults to None.\n        markup (bool, optional): Enable console markup in log messages. Defaults to Fals
4run_command
{
 "command": "grep -n \"from .traceback import Traceback\" rich/logging.py"
}
{"status": "ok", "stdout": "15:from .traceback import Traceback\n", "exit_code": 0}
full
{"status": "ok", "stdout": "15:from .traceback import Traceback\n", "exit_code": 0}
5-9 ×5read_file
{
 "filepath": "rich/logging.py"
}
{"status": "ok", "filepath": "rich/logging.py", "content": "import logging\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib
full
{"status": "ok", "filepath": "rich/logging.py", "content": "import logging\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib import Path\nfrom types import ModuleType\nfrom typing import ClassVar, Iterable, List, Optional, Type, Union\n\nfrom rich._null_file import NullFile\n\nfrom . import get_console\nfrom ._log_render import FormatTimeCallable, LogRender\nfrom .console import Console, ConsoleRenderable\nfrom .highlighter import Highlighter, ReprHighlighter\nfrom .text import Text\nfrom .traceback import Traceback\n\n\nclass RichHandler(Handler):\n    \"\"\"A logging handler that renders output with Rich. The time / level / message and file are displayed in columns.\n    The level is color coded, and the message is syntax highlighted.\n\n    Note:\n        Be careful when enabling console markup in log messages if you have configured logging for libraries not\n        under your control. If a dependency writes messages containing square brackets, it may not produce the intended output.\n\n    Args:\n        level (Union[int, str], optional): Log level. Defaults to logging.NOTSET.\n        console (:class:`~rich.console.Console`, optional): Optional console instance to write logs.\n            Default will use a global console instance writing to stdout.\n        show_time (bool, optional): Show a column for the time. Defaults to True.\n        omit_repeated_times (bool, optional): Omit repetition of the same time. Defaults to True.\n        show_level (bool, optional): Show a column for the level. Defaults to True.\n        show_path (bool, optional): Show the path to the original log call. Defaults to True.\n        enable_link_path (bool, optional): Enable terminal link of path column to file. Defaults to True.\n        highlighter (Highlighter, optional): Highlighter to style log messages, or None to use ReprHighlighter. Defaults to None.\n        markup (bool, optional): Enable console markup in log messages. Defaults to Fals
10run_command
{
 "command": "grep -n \"import Traceback\" rich/logging.py || grep -n \"from rich.traceback import Traceback\" rich/logging.py"
}
{"status": "ok", "stdout": "15:from .traceback import Traceback\n", "exit_code": 0}
full
{"status": "ok", "stdout": "15:from .traceback import Traceback\n", "exit_code": 0}
11run_command
{
 "command": "grep -n \"import inspect\" rich/console.py && grep -n \"import pretty\" rich/console.py && grep -n \"import scope\" rich/console.py && grep -n \"import getpass\" rich/console.py && grep -n \"import html\" rich/console.py && grep -n \"import zlib\" rich/console.py && grep -n \"def _svg_hash\" rich/console.py"
}
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "1:import inspect\n", "stderr": "",
full
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "1:import inspect\n", "stderr": "", "exit_code": 1}}
12run_command
{
 "command": "grep -n \"import logging\" rich/segment.py"
}
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
full
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
13run_command
{
 "command": "grep -n \"import configparser\" rich/theme.py"
}
{"status": "ok", "stdout": "1:import configparser\n", "exit_code": 0}
full
{"status": "ok", "stdout": "1:import configparser\n", "exit_code": 0}
14run_command
{
 "command": "grep -n \"from rich.console import Console, ConsoleOptions\" rich/syntax.py || grep -n \"import rich.console\" rich/syntax.py"
}
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
full
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
15run_command
{
 "command": "grep -n \"from inspect import isclass\" rich/protocol.py"
}
{"status": "ok", "stdout": "2:from inspect import isclass\n", "exit_code": 0}
full
{"status": "ok", "stdout": "2:from inspect import isclass\n", "exit_code": 0}
16run_command
{
 "command": "grep -n \"import inspect\" rich/repr.py"
}
{"status": "ok", "stdout": "1:import inspect\n", "exit_code": 0}
full
{"status": "ok", "stdout": "1:import inspect\n", "exit_code": 0}
17read_file
{
 "end_line": 30,
 "filepath": "rich/logging.py",
 "start_line": 1
}
{"status": "ok", "filepath": "rich/logging.py", "content": "import logging\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib
full
{"status": "ok", "filepath": "rich/logging.py", "content": "import logging\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib import Path\nfrom types import ModuleType\nfrom typing import ClassVar, Iterable, List, Optional, Type, Union\n\nfrom rich._null_file import NullFile\n\nfrom . import get_console\nfrom ._log_render import FormatTimeCallable, LogRender\nfrom .console import Console, ConsoleRenderable\nfrom .highlighter import Highlighter, ReprHighlighter\nfrom .text import Text\nfrom .traceback import Traceback\n\n\nclass RichHandler(Handler):\n    \"\"\"A logging handler that renders output with Rich. The time / level / message and file are displayed in columns.\n    The level is color coded, and the message is syntax highlighted.\n\n    Note:\n        Be careful when enabling console markup in log messages if you have configured logging for libraries not\n        under your control. If a dependency writes messages containing square brackets, it may not produce the intended output.\n\n    Args:\n        level (Union[int, str], optional): Log level. Defaults to logging.NOTSET.\n        console (:class:`~rich.console.Console`, optional): Optional console instance to write logs.\n            Default will use a global console instance writing to stdout.\n        show_time (bool, optional): Show a column for the time. Defaults to True.\n", "start_line": 1, "end_line": 30, "total_lines": 297, "is_truncated": false}
18read_file
{
 "end_line": 100,
 "filepath": "rich/console.py",
 "start_line": 1
}
{"status": "ok", "filepath": "rich/console.py", "content": "import inspect\nimport os\nimport sys\nimport threading\nimport zlib\nfrom abc import ABC, abstractm
full
{"status": "ok", "filepath": "rich/console.py", "content": "import inspect\nimport os\nimport sys\nimport threading\nimport zlib\nfrom abc import ABC, abstractmethod\nfrom dataclasses import dataclass, field\nfrom datetime import datetime\nfrom functools import wraps\nfrom getpass import getpass\nfrom html import escape\nfrom inspect import isclass\nfrom itertools import islice\nfrom math import ceil\nfrom time import monotonic\nfrom types import FrameType, ModuleType, TracebackType\nfrom typing import (\n    IO,\n    TYPE_CHECKING,\n    Any,\n    Callable,\n    Dict,\n    Iterable,\n    List,\n    Literal,\n    Mapping,\n    NamedTuple,\n    Optional,\n    Protocol,\n    TextIO,\n    Tuple,\n    Type,\n    Union,\n    cast,\n    runtime_checkable,\n)\n\nfrom rich._null_file import NULL_FILE\n\nfrom . import errors, themes\nfrom ._emoji_replace import _emoji_replace\nfrom ._export_format import CONSOLE_HTML_FORMAT, CONSOLE_SVG_FORMAT\nfrom ._fileno import get_fileno\nfrom ._log_render import FormatTimeCallable, LogRender\nfrom .align import Align, AlignMethod\nfrom .color import ColorSystem, blend_rgb\nfrom .control import Control\nfrom .emoji import EmojiVariant\nfrom .highlighter import NullHighlighter, ReprHighlighter\nfrom .markup import render as render_markup\nfrom .measure import Measurement, measure_renderables\nfrom .pager import Pager, SystemPager\nfrom .pretty import Pretty, is_expandable\nfrom .protocol import rich_cast\nfrom .region import Region\nfrom .scope import render_scope\nfrom .screen import Screen\nfrom .segment import Segment\nfrom .style import Style, StyleType\nfrom .styled import Styled\nfrom .terminal_theme import DEFAULT_TERMINAL_THEME, SVG_EXPORT_THEME, TerminalTheme\nfrom .text import Text, TextType\nfrom .theme import Theme, ThemeStack\n\nif TYPE_CHECKING:\n    from ._windows import WindowsConsoleFeatures\n    from .live import Live\n    from .status import Status\n\nJUPYTER_DEFAULT_COLUMNS = 115\nJUPYTER_DEFAULT_LINES = 100\nWINDOWS =
19read_file
{
 "end_line": 20,
 "filepath": "rich/segment.py",
 "start_line": 1
}
{"status": "ok", "filepath": "rich/segment.py", "content": "from enum import IntEnum\nfrom functools import lru_cache\nfrom itertools import filterfalse\nfrom l
full
{"status": "ok", "filepath": "rich/segment.py", "content": "from enum import IntEnum\nfrom functools import lru_cache\nfrom itertools import filterfalse\nfrom logging import getLogger\nfrom operator import attrgetter\nfrom typing import (\n    TYPE_CHECKING,\n    Dict,\n    Iterable,\n    List,\n    NamedTuple,\n    Optional,\n    Sequence,\n    Tuple,\n    Type,\n    Union,\n)\n\nfrom .cells import (\n    _is_single_cell_widths,\n", "start_line": 1, "end_line": 20, "total_lines": 783, "is_truncated": false}
20read_file
{
 "end_line": 20,
 "filepath": "rich/theme.py",
 "start_line": 1
}
{"status": "ok", "filepath": "rich/theme.py", "content": "import configparser\nfrom typing import IO, Dict, List, Mapping, Optional\n\nfrom .default_styles impo
full
{"status": "ok", "filepath": "rich/theme.py", "content": "import configparser\nfrom typing import IO, Dict, List, Mapping, Optional\n\nfrom .default_styles import DEFAULT_STYLES\nfrom .style import Style, StyleType\n\n\nclass Theme:\n    \"\"\"A container for style information, used by :class:`~rich.console.Console`.\n\n    Args:\n        styles (Dict[str, Style], optional): A mapping of style names on to styles. Defaults to None for a theme with no styles.\n        inherit (bool, optional): Inherit default styles. Defaults to True.\n    \"\"\"\n\n    styles: Dict[str, Style]\n\n    def __init__(\n        self, styles: Optional[Mapping[str, StyleType]] = None, inherit: bool = True\n    ):\n", "start_line": 1, "end_line": 20, "total_lines": 115, "is_truncated": false}
21read_file
{
 "end_line": 30,
 "filepath": "rich/syntax.py",
 "start_line": 1
}
{"status": "ok", "filepath": "rich/syntax.py", "content": "from __future__ import annotations\n\nimport os.path\nimport re\nimport sys\nimport textwrap\nfrom ab
full
{"status": "ok", "filepath": "rich/syntax.py", "content": "from __future__ import annotations\n\nimport os.path\nimport re\nimport sys\nimport textwrap\nfrom abc import ABC, abstractmethod\nfrom pathlib import Path\nfrom typing import (\n    Any,\n    Dict,\n    Iterable,\n    List,\n    NamedTuple,\n    Optional,\n    Sequence,\n    Set,\n    Tuple,\n    Type,\n    Union,\n)\n\nfrom pygments.lexer import Lexer\nfrom pygments.lexers import get_lexer_by_name, guess_lexer_for_filename\nfrom pygments.style import Style as PygmentsStyle\nfrom pygments.styles import get_style_by_name\nfrom pygments.token import (\n    Comment,\n    Error,\n    Generic,\n", "start_line": 1, "end_line": 30, "total_lines": 985, "is_truncated": false}
22read_file
{
 "end_line": 10,
 "filepath": "rich/protocol.py",
 "start_line": 1
}
{"status": "ok", "filepath": "rich/protocol.py", "content": "from typing import Any, cast, Set, TYPE_CHECKING\nfrom inspect import isclass\n\nif TYPE_CHECKING:\
full
{"status": "ok", "filepath": "rich/protocol.py", "content": "from typing import Any, cast, Set, TYPE_CHECKING\nfrom inspect import isclass\n\nif TYPE_CHECKING:\n    from rich.console import RenderableType\n\n_GIBBERISH = \"\"\"aihwerij235234ljsdnp34ksodfipwoe234234jlskjdf\"\"\"\n\n\ndef is_renderable(check_object: Any) -> bool:\n", "start_line": 1, "end_line": 10, "total_lines": 42, "is_truncated": false}
23read_file
{
 "end_line": 20,
 "filepath": "rich/repr.py",
 "start_line": 1
}
{"status": "ok", "filepath": "rich/repr.py", "content": "import inspect\nfrom functools import partial\nfrom typing import (\n Any,\n Callable,\n Iterable,\n Li
full
{"status": "ok", "filepath": "rich/repr.py", "content": "import inspect\nfrom functools import partial\nfrom typing import (\n    Any,\n    Callable,\n    Iterable,\n    List,\n    Optional,\n    Tuple,\n    Type,\n    TypeVar,\n    Union,\n    overload,\n)\n\nT = TypeVar(\"T\")\n\n\nResult = Iterable[Union[Any, Tuple[Any], Tuple[str, Any], Tuple[str, Any, Any]]]\nRichReprResult = Result\n", "start_line": 1, "end_line": 20, "total_lines": 149, "is_truncated": false}
24run_command
{
 "command": "grep -n \"emit(\" rich/logging.py && grep -n \"pathlib.Path\" rich/logging.py && grep -n \"def _svg_hash\" rich/console.py && grep -n \"def print(\" rich/console.py && grep -n \"def log(\" rich/console.py && grep -n \"def input(\" rich/console.py && grep -n \"def export\" rich/console.py && grep -n \"def from_file\" rich/theme.py && grep -n \"from rich.console import\" rich/syntax.py && grep -n \"def auto_rich_repr\" rich/repr.py"
}
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "132: def emit(self, record: LogReco
full
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "132:    def emit(self, record: LogRecord) -> None:\n", "stderr": "", "exit_code": 1}}
25run_command
{
 "command": "grep -n \"pathlib.Path\" rich/logging.py && grep -n \"def _svg_hash\" rich/console.py && grep -n \"def print(\" rich/console.py && grep -n \"def log(\" rich/console.py && grep -n \"def input(\" rich/console.py && grep -n \"def export\" rich/console.py && grep -n \"def from_file\" rich/theme.py && grep -n \"from rich.console import\" rich/syntax.py && grep -n \"def auto_rich_repr\" rich/repr.py"
}
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
full
{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
26run_command
{
 "command": "grep -n \"Path(\" rich/logging.py && grep -n \"_svg_hash\" rich/console.py && grep -n \"def print\" rich/console.py && grep -n \"def log\" rich/console.py && grep -n \"def input\" rich/console.py && grep -n \"def export\" rich/console.py && grep -n \"def from_file\" rich/theme.py && grep -n \"from .console import\" rich/syntax.py && grep -n \"def auto_rich_repr\" rich/repr.py"
}
{"status": "ok", "stdout": "224: path = Path(record.pathname).name\n2619:def _svg_hash(svg_main_code: str) -> str:\n1648: def print(\n1751: def print_json(\n186
full
{"status": "ok", "stdout": "224:        path = Path(record.pathname).name\n2619:def _svg_hash(svg_main_code: str) -> str:\n1648:    def print(\n1751:    def print_json(\n1866:    def print_exception(\n1936:    def log(\n2143:    def input(\n2177:    def export_text(self, *, clear: bool = True, styles: bool = False) -> str:\n2223:    def export_html(\n2329:    def export_svg(\n39:    def from_file(\n47:from .console import Console, ConsoleOptions, JustifyMethod, RenderResult\n68:        def auto_rich_repr(self: Type[T]) -> Result:\n", "exit_code": 0}
27read_file
{
 "end_line": 140,
 "filepath": "rich/logging.py",
 "start_line": 120
}
{"status": "ok", "filepath": "rich/logging.py", "content": " Args:\n record (LogRecord): LogRecord instance.\n\n Returns:\n Text: A tuple of the style and level
full
{"status": "ok", "filepath": "rich/logging.py", "content": "        Args:\n            record (LogRecord): LogRecord instance.\n\n        Returns:\n            Text: A tuple of the style and level name.\n        \"\"\"\n        level_name = record.levelname\n        level_text = Text.styled(\n            level_name.ljust(8), f\"logging.level.{level_name.lower()}\"\n        )\n        return level_text\n\n    def emit(self, record: LogRecord) -> None:\n        \"\"\"Invoked by logging.\"\"\"\n        message = self.format(record)\n        traceback = None\n        if (\n            self.rich_tracebacks\n            and record.exc_info\n            and record.exc_info != (None, None, None)\n        ):\n", "start_line": 120, "end_line": 140, "total_lines": 297, "is_truncated": false}
28read_file
{
 "end_line": 230,
 "filepath": "rich/logging.py",
 "start_line": 220
}
{"status": "ok", "filepath": "rich/logging.py", "content": "\n Returns:\n ConsoleRenderable: Renderable to display log.\n \"\"\"\n path = Path(record.pathname).
full
{"status": "ok", "filepath": "rich/logging.py", "content": "\n        Returns:\n            ConsoleRenderable: Renderable to display log.\n        \"\"\"\n        path = Path(record.pathname).name\n        level = self.get_level_text(record)\n        time_format = None if self.formatter is None else self.formatter.datefmt\n        log_time = datetime.fromtimestamp(record.created)\n\n        log_renderable = self._log_render(\n            self.console,\n", "start_line": 220, "end_line": 230, "total_lines": 297, "is_truncated": false}
29read_file
{
 "end_line": 1700,
 "filepath": "rich/console.py",
 "start_line": 1640
}
{"status": "ok", "filepath": "rich/console.py", "content": " emoji=False,\n markup=False,\n no_wrap=True,\n overflow=\"ignore\",\n crop=False,\n end=end,\n )\n\
full
{"status": "ok", "filepath": "rich/console.py", "content": "            emoji=False,\n            markup=False,\n            no_wrap=True,\n            overflow=\"ignore\",\n            crop=False,\n            end=end,\n        )\n\n    def print(\n        self,\n        *objects: Any,\n        sep: str = \" \",\n        end: str = \"\\n\",\n        style: Optional[Union[str, Style]] = None,\n        justify: Optional[JustifyMethod] = None,\n        overflow: Optional[OverflowMethod] = None,\n        no_wrap: Optional[bool] = None,\n        emoji: Optional[bool] = None,\n        markup: Optional[bool] = None,\n        highlight: Optional[bool] = None,\n        width: Optional[int] = None,\n        height: Optional[int] = None,\n        crop: bool = True,\n        soft_wrap: Optional[bool] = None,\n        new_line_start: bool = False,\n    ) -> None:\n        \"\"\"Print to the console.\n\n        Args:\n            objects (positional args): Objects to log to the terminal.\n            sep (str, optional): String to write between print data. Defaults to \" \".\n            end (str, optional): String to write at end of print data. Defaults to \"\\\\\\\\n\".\n            style (Union[str, Style], optional): A style to apply to output. Defaults to None.\n            justify (str, optional): Justify method: \"default\", \"left\", \"right\", \"center\", or \"full\". Defaults to ``None``.\n            overflow (str, optional): Overflow method: \"ignore\", \"crop\", \"fold\", or \"ellipsis\". Defaults to None.\n            no_wrap (Optional[bool], optional): Disable word wrapping. Defaults to None.\n            emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. Defaults to ``None``.\n            markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. Defaults to ``None``.\n            highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to ``N
30read_file
{
 "end_line": 2000,
 "filepath": "rich/console.py",
 "start_line": 1930
}
{"status": "ok", "filepath": "rich/console.py", "content": " return frame.f_code.co_filename, frame.f_lineno, frame.f_locals\n else:\n # Fallback to the slower
full
{"status": "ok", "filepath": "rich/console.py", "content": "            return frame.f_code.co_filename, frame.f_lineno, frame.f_locals\n        else:\n            # Fallback to the slower stack\n            frame_info = inspect.stack()[offset]\n            return frame_info.filename, frame_info.lineno, frame_info.frame.f_locals\n\n    def log(\n        self,\n        *objects: Any,\n        sep: str = \" \",\n        end: str = \"\\n\",\n        style: Optional[Union[str, Style]] = None,\n        justify: Optional[JustifyMethod] = None,\n        emoji: Optional[bool] = None,\n        markup: Optional[bool] = None,\n        highlight: Optional[bool] = None,\n        log_locals: bool = False,\n        _stack_offset: int = 1,\n    ) -> None:\n        \"\"\"Log rich content to the terminal.\n\n        Args:\n            objects (positional args): Objects to log to the terminal.\n            sep (str, optional): String to write between print data. Defaults to \" \".\n            end (str, optional): String to write at end of print data. Defaults to \"\\\\\\\\n\".\n            style (Union[str, Style], optional): A style to apply to output. Defaults to None.\n            justify (str, optional): One of \"left\", \"right\", \"center\", or \"full\". Defaults to ``None``.\n            emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. Defaults to None.\n            markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. Defaults to None.\n            highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to None.\n            log_locals (bool, optional): Boolean to enable logging of locals where ``log()``\n                was called. Defaults to False.\n            _stack_offset (int, optional): Offset of caller from end of call stack. Defaults to 1.\n        \"\"\"\n        if not objects:\n            objects = (NewLine(),)\n\n        render_hooks
31read_file
{
 "end_line": 2200,
 "filepath": "rich/console.py",
 "start_line": 2130
}
{"status": "ok", "filepath": "rich/console.py", "content": " append(\n style.render(\n text,\n color_system=color_system,\n legacy_windows=legacy_windows,\n )\n
full
{"status": "ok", "filepath": "rich/console.py", "content": "                append(\n                    style.render(\n                        text,\n                        color_system=color_system,\n                        legacy_windows=legacy_windows,\n                    )\n                )\n            elif not (not_terminal and control):\n                append(text)\n\n        rendered = \"\".join(output)\n        return rendered\n\n    def input(\n        self,\n        prompt: TextType = \"\",\n        *,\n        markup: bool = True,\n        emoji: bool = True,\n        password: bool = False,\n        stream: Optional[TextIO] = None,\n    ) -> str:\n        \"\"\"Displays a prompt and waits for input from the user. The prompt may contain color / style.\n\n        It works in the same way as Python's builtin :func:`input` function and provides elaborate line editing and history features if Python's builtin :mod:`readline` module is previously loaded.\n\n        Args:\n            prompt (Union[str, Text]): Text to render in the prompt.\n            markup (bool, optional): Enable console markup (requires a str prompt). Defaults to True.\n            emoji (bool, optional): Enable emoji (requires a str prompt). Defaults to True.\n            password: (bool, optional): Hide typed text. Defaults to False.\n            stream: (TextIO, optional): Optional file to read input from (rather than stdin). Defaults to None.\n\n        Returns:\n            str: Text read from stdin.\n        \"\"\"\n        if prompt:\n            self.print(prompt, markup=markup, emoji=emoji, end=\"\")\n        if password:\n            result = getpass(\"\", stream=stream)\n        else:\n            if stream:\n                result = stream.readline()\n            else:\n                result = input()\n        return result\n\n    def export_text(self, *, clear: bool = True, styles: bool = False) -> str:\n        \"\"\"Generate text from console contents (requires record
32read_file
{
 "end_line": 2400,
 "filepath": "rich/console.py",
 "start_line": 2170
}
{"status": "ok", "filepath": "rich/console.py", "content": " else:\n if stream:\n result = stream.readline()\n else:\n result = input()\n return result\n\n def
full
{"status": "ok", "filepath": "rich/console.py", "content": "        else:\n            if stream:\n                result = stream.readline()\n            else:\n                result = input()\n        return result\n\n    def export_text(self, *, clear: bool = True, styles: bool = False) -> str:\n        \"\"\"Generate text from console contents (requires record=True argument in constructor).\n\n        Args:\n            clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``.\n            styles (bool, optional): If ``True``, ansi escape codes will be included. ``False`` for plain text.\n                Defaults to ``False``.\n\n        Returns:\n            str: String containing console contents.\n\n        \"\"\"\n        assert (\n            self.record\n        ), \"To export console contents set record=True in the constructor or instance\"\n\n        with self._record_buffer_lock:\n            if styles:\n                text = \"\".join(\n                    (style.render(text) if style else text)\n                    for text, style, _ in self._record_buffer\n                )\n            else:\n                text = \"\".join(\n                    segment.text\n                    for segment in self._record_buffer\n                    if not segment.control\n                )\n            if clear:\n                del self._record_buffer[:]\n        return text\n\n    def save_text(self, path: str, *, clear: bool = True, styles: bool = False) -> None:\n        \"\"\"Generate text from console and save to a given location (requires record=True argument in constructor).\n\n        Args:\n            path (str): Path to write text files.\n            clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``.\n            styles (bool, optional): If ``True``, ansi style codes will be included. ``False`` for plain text.\n                Defaults to ``False``.\n\n        \"\"\"\n        text = self.expor
33read_file
{
 "end_line": 2650,
 "filepath": "rich/console.py",
 "start_line": 2600
}
{"status": "ok", "filepath": "rich/console.py", "content": " injected by Rich can be found by inspecting the ``console.CONSOLE_SVG_FORMAT`` variable.\n font_asp
full
{"status": "ok", "filepath": "rich/console.py", "content": "                injected by Rich can be found by inspecting the ``console.CONSOLE_SVG_FORMAT`` variable.\n            font_aspect_ratio (float, optional): The width to height ratio of the font used in the ``code_format``\n                string. Defaults to 0.61, which is the width to height ratio of Fira Code (the default font).\n                If you aren't specifying a different font inside ``code_format``, you probably don't need this.\n            unique_id (str, optional): unique id that is used as the prefix for various elements (CSS styles, node\n                ids). If not set, this defaults to a computed value based on the recorded content.\n        \"\"\"\n        svg = self.export_svg(\n            title=title,\n            theme=theme,\n            clear=clear,\n            code_format=code_format,\n            font_aspect_ratio=font_aspect_ratio,\n            unique_id=unique_id,\n        )\n        with open(path, \"w\", encoding=\"utf-8\") as write_file:\n            write_file.write(svg)\n\n\ndef _svg_hash(svg_main_code: str) -> str:\n    \"\"\"Returns a unique hash for the given SVG main code.\n\n    Args:\n        svg_main_code (str): The content we're going to inject in the SVG envelope.\n\n    Returns:\n        str: a hash of the given content\n    \"\"\"\n    return str(zlib.adler32(svg_main_code.encode()))\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    console = Console(record=True)\n\n    console.log(\n        \"JSONRPC [i]request[/i]\",\n        5,\n        1.3,\n        True,\n        False,\n        None,\n        {\n            \"jsonrpc\": \"2.0\",\n            \"method\": \"subtract\",\n            \"params\": {\"minuend\": 42, \"subtrahend\": 23},\n            \"id\": 3,\n        },\n    )\n\n    console.log(\"Hello, World!\", \"{'a': 1}\", repr(console))\n\n", "start_line": 2600, "end_line": 2650, "total_lines": 2684, "is_truncated": false}
34read_file
{
 "end_line": 50,
 "filepath": "rich/theme.py",
 "start_line": 30
}
{"status": "ok", "filepath": "rich/theme.py", "content": " @property\n def config(self) -> str:\n \"\"\"Get contents of a config file for this theme.\"\"\"\n co
full
{"status": "ok", "filepath": "rich/theme.py", "content": "    @property\n    def config(self) -> str:\n        \"\"\"Get contents of a config file for this theme.\"\"\"\n        config = \"[styles]\\n\" + \"\\n\".join(\n            f\"{name} = {style}\" for name, style in sorted(self.styles.items())\n        )\n        return config\n\n    @classmethod\n    def from_file(\n        cls, config_file: IO[str], source: Optional[str] = None, inherit: bool = True\n    ) -> \"Theme\":\n        \"\"\"Load a theme from a text mode file.\n\n        Args:\n            config_file (IO[str]): An open conf file.\n            source (str, optional): The filename of the open file. Defaults to None.\n            inherit (bool, optional): Inherit default styles. Defaults to True.\n\n        Returns:\n            Theme: A New theme instance.\n", "start_line": 30, "end_line": 50, "total_lines": 115, "is_truncated": false}
35read_file
{
 "filepath": "rich/logging.py"
}
{"status": "ok", "filepath": "rich/logging.py", "content": "import logging\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib
full
{"status": "ok", "filepath": "rich/logging.py", "content": "import logging\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib import Path\nfrom types import ModuleType\nfrom typing import ClassVar, Iterable, List, Optional, Type, Union\n\nfrom rich._null_file import NullFile\n\nfrom . import get_console\nfrom ._log_render import FormatTimeCallable, LogRender\nfrom .console import Console, ConsoleRenderable\nfrom .highlighter import Highlighter, ReprHighlighter\nfrom .text import Text\nfrom .traceback import Traceback\n\n\nclass RichHandler(Handler):\n    \"\"\"A logging handler that renders output with Rich. The time / level / message and file are displayed in columns.\n    The level is color coded, and the message is syntax highlighted.\n\n    Note:\n        Be careful when enabling console markup in log messages if you have configured logging for libraries not\n        under your control. If a dependency writes messages containing square brackets, it may not produce the intended output.\n\n    Args:\n        level (Union[int, str], optional): Log level. Defaults to logging.NOTSET.\n        console (:class:`~rich.console.Console`, optional): Optional console instance to write logs.\n            Default will use a global console instance writing to stdout.\n        show_time (bool, optional): Show a column for the time. Defaults to True.\n        omit_repeated_times (bool, optional): Omit repetition of the same time. Defaults to True.\n        show_level (bool, optional): Show a column for the level. Defaults to True.\n        show_path (bool, optional): Show the path to the original log call. Defaults to True.\n        enable_link_path (bool, optional): Enable terminal link of path column to file. Defaults to True.\n        highlighter (Highlighter, optional): Highlighter to style log messages, or None to use ReprHighlighter. Defaults to None.\n        markup (bool, optional): Enable console markup in log messages. Defaults to Fals
36edit_file
{
 "filepath": "rich/logging.py",
 "new_string": "from __future__ import annotations\n\nimport logging\nimport os\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib import Path\nfrom types import ModuleType\nfrom typing import TYPE_CHECKING, ClassVar, Iterable, List, Optional, Type, Union\n\nif TYPE_CHECKING:\n    from ._log_render import FormatTimeCallable\n    from .console import Console, ConsoleRenderable\n    from .highlighter import Highlighter\n\nfrom rich._null_file import NullFile\n\nfrom . import get_console\nfrom ._log_render import LogRender\nfrom .highlighter import ReprHighlighter\nfrom .text import Text\n",
 "old_string": "import logging\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib import Path\nfrom types import ModuleType\nfrom typing import ClassVar, Iterable, List, Optional, Type, Union\n\nfrom rich._null_file import NullFile\n\nfrom . import get_console\nfrom ._log_render import FormatTimeCallable, LogRender\nfrom .console import Console, ConsoleRenderable\nfrom .highlighter import Highlighter, ReprHighlighter\nfrom .text import Text\nfrom .traceback import Traceback\n"
}
{"status": "ok", "filepath": "rich/logging.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/logging.py\n+++ b/rich/logging.py\n@@ -1,18 +1,24 @@\
full
{"status": "ok", "filepath": "rich/logging.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/logging.py\n+++ b/rich/logging.py\n@@ -1,18 +1,24 @@\n+from __future__ import annotations\n+\n import logging\n+import os\n from datetime import datetime\n from logging import Handler, LogRecord\n from pathlib import Path\n from types import ModuleType\n-from typing import ClassVar, Iterable, List, Optional, Type, Union\n+from typing import TYPE_CHECKING, ClassVar, Iterable, List, Optional, Type, Union\n+\n+if TYPE_CHECKING:\n+    from ._log_render import FormatTimeCallable\n+    from .console import Console, ConsoleRenderable\n+    from .highlighter import Highlighter\n \n from rich._null_file import NullFile\n \n from . import get_console\n-from ._log_render import FormatTimeCallable, LogRender\n-from .console import Console, ConsoleRenderable\n-from .highlighter import Highlighter, ReprHighlighter\n+from ._log_render import LogRender\n+from .highlighter import ReprHighlighter\n from .text import Text\n-from .traceback import Traceback\n \n \n class RichHandler(Handler):\n", "is_truncated": false}
37read_file
{
 "filepath": "rich/logging.py"
}
{"status": "ok", "filepath": "rich/logging.py", "content": "from __future__ import annotations\n\nimport logging\nimport os\nfrom datetime import datetime\nfrom
full
{"status": "ok", "filepath": "rich/logging.py", "content": "from __future__ import annotations\n\nimport logging\nimport os\nfrom datetime import datetime\nfrom logging import Handler, LogRecord\nfrom pathlib import Path\nfrom types import ModuleType\nfrom typing import TYPE_CHECKING, ClassVar, Iterable, List, Optional, Type, Union\n\nif TYPE_CHECKING:\n    from ._log_render import FormatTimeCallable\n    from .console import Console, ConsoleRenderable\n    from .highlighter import Highlighter\n\nfrom rich._null_file import NullFile\n\nfrom . import get_console\nfrom ._log_render import LogRender\nfrom .highlighter import ReprHighlighter\nfrom .text import Text\n\n\nclass RichHandler(Handler):\n    \"\"\"A logging handler that renders output with Rich. The time / level / message and file are displayed in columns.\n    The level is color coded, and the message is syntax highlighted.\n\n    Note:\n        Be careful when enabling console markup in log messages if you have configured logging for libraries not\n        under your control. If a dependency writes messages containing square brackets, it may not produce the intended output.\n\n    Args:\n        level (Union[int, str], optional): Log level. Defaults to logging.NOTSET.\n        console (:class:`~rich.console.Console`, optional): Optional console instance to write logs.\n            Default will use a global console instance writing to stdout.\n        show_time (bool, optional): Show a column for the time. Defaults to True.\n        omit_repeated_times (bool, optional): Omit repetition of the same time. Defaults to True.\n        show_level (bool, optional): Show a column for the level. Defaults to True.\n        show_path (bool, optional): Show the path to the original log call. Defaults to True.\n        enable_link_path (bool, optional): Enable terminal link of path column to file. Defaults to True.\n        highlighter (Highlighter, optional): Highlighter to style log messages, or None to use ReprHighlig

Patch

diff --git a/rich/logging.py b/rich/logging.py
index c3e7a5f6..22524edc 100644
--- a/rich/logging.py
+++ b/rich/logging.py
@@ -1,18 +1,24 @@
+from __future__ import annotations
+
 import logging
+import os
 from datetime import datetime
 from logging import Handler, LogRecord
 from pathlib import Path
 from types import ModuleType
-from typing import ClassVar, Iterable, List, Optional, Type, Union
+from typing import TYPE_CHECKING, ClassVar, Iterable, List, Optional, Type, Union
+
+if TYPE_CHECKING:
+    from ._log_render import FormatTimeCallable
+    from .console import Console, ConsoleRenderable
+    from .highlighter import Highlighter
 
 from rich._null_file import NullFile
 
 from . import get_console
-from ._log_render import FormatTimeCallable, LogRender
-from .console import Console, ConsoleRenderable
-from .highlighter import Highlighter, ReprHighlighter
+from ._log_render import LogRender
+from .highlighter import ReprHighlighter
 from .text import Text
-from .traceback import Traceback
 
 
 class RichHandler(Handler):

Test output

show
..........................................F
=================================== FAILURES ===================================
_____________________________ test_input_password ______________________________

prompt = '', stream = None

    def unix_getpass(prompt='Password: ', stream=None):
        """Prompt for a password, with echo turned off.
    
        Args:
          prompt: Written on stream to ask for the input.  Default: 'Password: '
          stream: A writable file object to display the prompt.  Defaults to
                  the tty.  If no tty is available defaults to sys.stderr.
        Returns:
          The seKr3t input.
        Raises:
          EOFError: If our input tty or stdin was closed.
          GetPassWarning: When we were unable to turn echo off on the input.
    
        Always restores terminal settings before returning.
        """
        passwd = None
        with contextlib.ExitStack() as stack:
            try:
                # Always try reading and writing directly on the tty first.
>               fd = os.open('/dev/tty', os.O_RDWR|os.O_NOCTTY)
E               OSError: [Errno 6] No such device or address: '/dev/tty'

/root/.local/share/uv/python/cpython-3.13.14-linux-x86_64-gnu/lib/python3.13/getpass.py:47: OSError

During handling of the above exception, another exception occurred:

prompt = '', stream = None

    def unix_getpass(prompt='Password: ', stream=None):
        """Prompt for a password, with echo turned off.
    
        Args:
          prompt: Written on stream to ask for the input.  Default: 'Password: '
          stream: A writable file object to display the prompt.  Defaults to
                  the tty.  If no tty is available defaults to sys.stderr.
        Returns:
          The seKr3t input.
        Raises:
          EOFError: If our input tty or stdin was closed.
          GetPassWarning: When we were unable to turn echo off on the input.
    
        Always restores terminal settings before returning.
        """
        passwd = None
        with contextlib.ExitStack() as stack:
            try:
                # Always try reading and writing directly on the tty first.
                fd = os.open('/dev/tty', os.O_RDWR|os.O_NOCTTY)
                tty = io.FileIO(fd, 'w+')
                stack.enter_context(tty)
                input = io.TextIOWrapper(tty)
                stack.enter_context(input)
                if not stream:
                    stream = input
            except OSError:
                # If that fails, see if stdin can be controlled.
                stack.close()
                try:
>                   fd = sys.stdin.fileno()
E                   io.UnsupportedOperation: redirected stdin is pseudofile, has no fileno()

/root/.local/share/uv/python/cpython-3.13.14-linux-x86_64-gnu/lib/python3.13/getpass.py:58: UnsupportedOperation

During handling of the above exception, another exception occurred:

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7d08df915940>
capsys = <_pytest.capture.CaptureFixture object at 0x7d08dfb30e10>

    def test_input_password(monkeypatch, capsys) -> None:
        def fake_input(prompt, stream=None):
            console.file.write(prompt)
            return "bar"
    
        import getpass
    
        monkeypatch.setattr(getpass, "getpass", fake_input)
        console = Console()
>       user_input = console.input(prompt="foo:", password=True)

tests/test_console.py:407: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
rich/console.py:2169: in input
    result = getpass("", stream=stream)
/root/.local/share/uv/python/cpython-3.13.14-linux-x86_64-gnu/lib/python3.13/getpass.py:61: in unix_getpass
    passwd = fallback_getpass(prompt, stream)
/root/.local/share/uv/python/cpython-3.13.14-linux-x86_64-gnu/lib/python3.13/getpass.py:126: in fallback_getpass
    return _raw_input(prompt, stream)
/root/.local/share/uv/python/cpython-3.13.14-linux-x86_64-gnu/lib/python3.13/getpass.py:146: in _raw_input
    line = input.readline()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.capture.DontReadFromInput object at 0x7d08dfb8dfd0>, size = -1

    def read(self, size: int = -1) -> str:
>       raise OSError(
            "pytest: reading from stdin while output is captured!  Consider using `-s`."
        )
E       OSError: pytest: reading from stdin while output is captured!  Consider using `-s`.

/kaggle/tmp/envs/rich/lib/python3.13/site-packages/_pytest/capture.py:209: OSError
----------------------------- Captured stdout call -----------------------------
foo:
----------------------------- Captured stderr call -----------------------------
Warning: Password input may be echoed.
=============================== warnings summary ===============================
test_console.py::test_input_password
  /root/.local/share/uv/python/cpython-3.13.14-linux-x86_64-gnu/lib/python3.13/getpass.py:61: GetPassWarning: Can not control echo on the terminal.
    passwd = fallback_getpass(prompt, stream)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 42 passed, 1 warning in 0.49s