Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.

Home Page:https://rich.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[REQUEST] Increase default terminal width in GitHub Actions

samuelcolvin opened this issue · comments

Have you checked the issues for a similar suggestions?

yes

How would you improve Rich?

Currently the terminal width is very narrow in github actions, making content, particuarly in tables hard to read, or missing completely.

Example: https://github.com/pydantic/pydantic-core/actions/runs/3933397938/jobs/6727055614

Screenshot 2023-01-22 at 12 31 56

Would be great if rich could detect that it's being used in github actions and use a wider default width.


Otherwise/until this is changed, is there a env var I can see to increase the default?

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

(Comes from use of rich via pytest-pretty)

You can set the COLUMNS env var. There’s no other way for Rich to detect the width when not writing to a real tty

I understand you can't detect the width, but you could detect with a high detect of confidence that you're in a github action, and increase the default width?

Increase it to what though? There’s no optional width for everyone. Any value I pick will be wrong for someone. And if I go down road route I’ll soon have a load of spaghetti logic to try and detect what CI system is in use.

I think think is best left to the user. Columns being a standard env var that might already be set.

I get that, but I think github actions is so widely used that something like

# GitHub Actions is extremely widely used, so we make an exception for it
# and increase the default terminal width
if os.getenv('GITHUB_ACTION'):
    default_columns = 120
else:
    default_columns = ...

Wouldn't be too crazy.

But I also understand if you don't want to.


For anyone else coming to this, adding the following the to the top level of your workflow file helps rich and also appears to help pytest.

env:
  COLUMNS: 120

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual