Skip to content

Commit

Permalink
Merge branch 'master' into escape-codes-in-repr
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan authored Aug 17, 2022
2 parents 98d890b + 828db35 commit 2c3180f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased]

### Added

- Parse ANSI escape sequences in pretty repr https://github.com/Textualize/rich/pull/2470
- Add support for `FORCE_COLOR` env var https://github.com/Textualize/rich/pull/2449

### Fixed

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The following people have contributed to the development of Rich:
- [Kylian Point](https://github.com/p0lux)
- [Kyle Pollina](https://github.com/kylepollina)
- [Sebastián Ramírez](https://github.com/tiangolo)
- [Felipe Guedes](https://github.com/guedesfelipe)
- [Clément Robert](https://github.com/neutrinoceros)
- [Brian Rutledge](https://github.com/bhrutledge)
- [Tushar Sadhwani](https://github.com/tusharsadhwani)
Expand Down
7 changes: 6 additions & 1 deletion rich/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,12 @@ def __init__(
self._height = height

self._color_system: Optional[ColorSystem]
self._force_terminal = force_terminal

if force_terminal is not None:
self._force_terminal = force_terminal
else:
self._force_terminal = self._environ.get("FORCE_COLOR") is not None

self._file = file
self.quiet = quiet
self.stderr = stderr
Expand Down
8 changes: 4 additions & 4 deletions rich/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def track(
refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.done".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1.
disable (bool, optional): Disable display of progress.
Expand Down Expand Up @@ -315,7 +315,7 @@ def wrap_file(
refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.done".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
disable (bool, optional): Disable display of progress.
Returns:
Expand Down Expand Up @@ -440,7 +440,7 @@ def open(
refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.done".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
disable (bool, optional): Disable display of progress.
encoding (str, optional): The encoding to use when reading in text mode.
Expand Down Expand Up @@ -634,7 +634,7 @@ class BarColumn(ProgressColumn):
bar_width (Optional[int], optional): Width of bar or None for full width. Defaults to 40.
style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.done".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
"""

Expand Down
2 changes: 1 addition & 1 deletion rich/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ProgressBar(JupyterMixin):
pulse (bool, optional): Enable pulse effect. Defaults to False. Will pulse if a None total was passed.
style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.done".
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
animation_time (Optional[float], optional): Time in seconds to use for animation, or None to use system time.
"""
Expand Down
8 changes: 8 additions & 0 deletions tests/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,3 +895,11 @@ def test_render_lines_height_minus_vertical_pad_is_negative():

# Ensuring that no exception is raised...
console.render_lines(Padding("hello", pad=(1, 0)), options=options)


@mock.patch.dict(os.environ, {"FORCE_COLOR": "anything"})
def test_force_color():
# Even though we use a non-tty file, the presence of FORCE_COLOR env var
# means is_terminal returns True.
console = Console(file=io.StringIO())
assert console.is_terminal

0 comments on commit 2c3180f

Please sign in to comment.