Skip to content

Disable hard-wrapping for all console print functions#1656

Open
Copilot wants to merge 3 commits intomainfrom
copilot/disable-hard-wrapping-all-commands
Open

Disable hard-wrapping for all console print functions#1656
Copilot wants to merge 3 commits intomainfrom
copilot/disable-hard-wrapping-all-commands

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

Most styled print functions (tick_print, instruct_print, how_print, info_print, err_print, warn_print) lacked soft_wrap=True on their Rich console.print() calls, causing hard-wrapping at terminal width. Tests worked around this with .replace("\n", "") hacks.

Changes

  • src/usethis/_console.py: Added soft_wrap=True to all 6 affected console.print() calls, matching plain_print() and table_print() which already had it:
    console.print(f"{icon} {msg}", style="green", soft_wrap=True)
  • Tests (4 files, 12 workarounds removed): Replaced .replace("\n", "") and .replace("\n", " ").replace(" ", " ") hacks with exact == assertions using proper \n terminators
  • tests/usethis/test_console.py: Added test_no_line_wrapping for each styled print function, verifying 200-char messages aren't wrapped
  • docs/functions.txt, AGENTS.md: Auto-generated sync from prek hooks (pre-existing gap, unrelated)

Copilot AI and others added 2 commits March 30, 2026 22:30
…karounds

- Add soft_wrap=True to tick_print, instruct_print, how_print, info_print,
  err_print, and warn_print (via _cached_warn_print) in _console.py
- Remove .replace("\n", "") workarounds from test_core_tool.py (7 instances)
- Remove .replace("\n", "") workarounds from test_rule.py (2 instances)
- Remove .replace("\n", "") workarounds from test_lint.py (2 instances)
- Remove .replace("\n", " ").replace("  ", " ") workaround from test_base.py
- Add test_no_line_wrapping tests for tick_print, instruct_print, info_print,
  err_print, and warn_print in test_console.py

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/83ad3589-83a9-4f1f-8e8c-bacca08c9660

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with hard-wrapping in commands Disable hard-wrapping for all console print functions Mar 30, 2026
Copilot AI requested a review from nathanjmcdougall March 30, 2026 22:34
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review March 30, 2026 22:40
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 30, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/disable-hard-wrapping-all-commands (466a067) with main (b438c90)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable hard-wrapping for all commands

2 participants