Skip to content

Commit

Permalink
Merge pull request Textualize#1583 from GBeauregard/typing-investigation
Browse files Browse the repository at this point in the history
Fix Justify default incorrectly set to DEFAULT_OVERFLOW
  • Loading branch information
willmcgugan authored Oct 15, 2021
2 parents 5b9f55f + 69f197c commit 8efebcf
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions rich/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
Optional,
Tuple,
Union,
cast,
)

from ._loop import loop_last
Expand Down Expand Up @@ -144,8 +143,8 @@ def __init__(
) -> None:
self._text = [strip_control_codes(text)]
self.style = style
self.justify = justify
self.overflow = overflow
self.justify: Optional["JustifyMethod"] = justify
self.overflow: Optional["OverflowMethod"] = overflow
self.no_wrap = no_wrap
self.end = end
self.tab_size = tab_size
Expand Down Expand Up @@ -555,15 +554,9 @@ def __rich_console__(
self, console: "Console", options: "ConsoleOptions"
) -> Iterable[Segment]:
tab_size: int = console.tab_size or self.tab_size or 8
justify = (
cast("JustifyMethod", self.justify) or options.justify or DEFAULT_OVERFLOW
)
justify = self.justify or options.justify or DEFAULT_JUSTIFY

overflow = (
cast("OverflowMethod", self.overflow)
or options.overflow
or DEFAULT_OVERFLOW
)
overflow = self.overflow or options.overflow or DEFAULT_OVERFLOW

lines = self.wrap(
console,
Expand Down Expand Up @@ -1065,10 +1058,8 @@ def wrap(
Returns:
Lines: Number of lines.
"""
wrap_justify = cast("JustifyMethod", justify or self.justify) or DEFAULT_JUSTIFY
wrap_overflow = (
cast("OverflowMethod", overflow or self.overflow) or DEFAULT_OVERFLOW
)
wrap_justify = justify or self.justify or DEFAULT_JUSTIFY
wrap_overflow = overflow or self.overflow or DEFAULT_OVERFLOW

no_wrap = pick_bool(no_wrap, self.no_wrap, False) or overflow == "ignore"

Expand Down

0 comments on commit 8efebcf

Please sign in to comment.