Skip to content

Conversation

@eendebakpt
Copy link

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Enable colored output with Spyder

This PR addresses two issues:

  • colorama needs to be initialized with the option strip=False in Spyder
  • In the spyder environment the method is_terminal returns False, where it should return True. This is solved by creating a new method detect_spyder_environment

Related: #1149, spyder-ide/spyder#15496, spyder-ide/spyder#1917

A screenshot of Spyder with the PR:

image

@willmcgugan
Copy link
Member

I can't accept a fudge for a specific IDE. Colorama is a headache for Rich as it makes global changes, whereas Rich can have different settings per-Console instance.

I'd suggest setting force_terminal on the constructor if Spyder is reporting it is not a real terminal. You can also reinit colorama after importing rich to fix that issue.

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.

2 participants