Skip to content

Commit

Permalink
Merge pull request #1245 from willmcgugan/status-text
Browse files Browse the repository at this point in the history
fix status text
  • Loading branch information
willmcgugan authored May 19, 2021
2 parents fd4f1bc + 540e887 commit a81230b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.6", "3.7", "3.8", "3.9"]
defaults:
run:
shell: bash
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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).

## [10.2.2] - 2021-05-19

### Fixed

- Fixed status not rendering console markup https://github.com/willmcgugan/rich/issues/1244

## [10.2.1] - 2021-05-17

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "rich"
homepage = "https://github.com/willmcgugan/rich"
documentation = "https://rich.readthedocs.io/en/latest/"
version = "10.2.1"
version = "10.2.2"
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
authors = ["Will McGugan <[email protected]>"]
license = "MIT"
Expand All @@ -18,6 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Typing :: Typed"
]
include = ["rich/py.typed"]
Expand Down
4 changes: 2 additions & 2 deletions rich/spinner.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(
spinner = SPINNERS[name]
except KeyError:
raise KeyError(f"no spinner called {name!r}")
self.text = text
self.text = Text.from_markup(text) if isinstance(text, str) else text
self.frames = cast(List[str], spinner["frames"])[:]
self.interval = cast(float, spinner["interval"])
self.start_time: Optional[float] = None
Expand Down Expand Up @@ -103,7 +103,7 @@ def update(
speed (float, optional): Speed factor for animation. Defaults to None.
"""
if text:
self.text = text
self.text = Text.from_markup(text) if isinstance(text, str) else text
if style:
self.style = style
if speed:
Expand Down
16 changes: 12 additions & 4 deletions tests/test_segment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

from rich.segment import ControlType
from rich.segment import Segment
from rich.style import Style
Expand All @@ -6,10 +8,16 @@
def test_repr():
assert repr(Segment("foo")) == "Segment('foo', None)"
home = (ControlType.HOME, 0)
assert (
repr(Segment("foo", None, [home]))
== "Segment('foo', None, [(<ControlType.HOME: 3>, 0)])"
)
if sys.version_info >= (3, 10):
assert (
repr(Segment("foo", None, [home]))
== "Segment('foo', None, [(ControlType.HOME, 0)])"
)
else:
assert (
repr(Segment("foo", None, [home]))
== "Segment('foo', None, [(<ControlType.HOME: 3>, 0)])"
)


def test_line():
Expand Down
7 changes: 7 additions & 0 deletions tests/test_spinner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from rich.measure import Measurement
from rich.rule import Rule
from rich.spinner import Spinner
from rich.text import Text


def test_spinner_create():
Expand Down Expand Up @@ -65,3 +66,9 @@ def test_rich_measure():
min_width, max_width = Measurement.get(console, console.options, spinner)
assert min_width == 3
assert max_width == 5


def test_spinner_markup():
spinner = Spinner("dots", "[bold]spinning[/bold]")
assert isinstance(spinner.text, Text)
assert str(spinner.text) == "spinning"

0 comments on commit a81230b

Please sign in to comment.