Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Oct 1, 2024
1 parent 67e68f3 commit 45b7cef
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion rich/_null_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __iter__(self) -> Iterator[str]:
return iter([""])

def __enter__(self) -> IO[str]:
pass
return self

def __exit__(
self,
Expand Down
8 changes: 4 additions & 4 deletions rich/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ class NoChange:
NO_CHANGE = NoChange()

try:
_STDIN_FILENO = sys.__stdin__.fileno()
_STDIN_FILENO = sys.__stdin__.fileno() # type: ignore[union-attr]
except Exception:
_STDIN_FILENO = 0
try:
_STDOUT_FILENO = sys.__stdout__.fileno()
_STDOUT_FILENO = sys.__stdout__.fileno() # type: ignore[union-attr]
except Exception:
_STDOUT_FILENO = 1
try:
_STDERR_FILENO = sys.__stderr__.fileno()
_STDERR_FILENO = sys.__stderr__.fileno() # type: ignore[union-attr]
except Exception:
_STDERR_FILENO = 2

Expand Down Expand Up @@ -1302,7 +1302,7 @@ def render(

renderable = rich_cast(renderable)
if hasattr(renderable, "__rich_console__") and not isclass(renderable):
render_iterable = renderable.__rich_console__(self, _options) # type: ignore[union-attr]
render_iterable = renderable.__rich_console__(self, _options)
elif isinstance(renderable, str):
text_renderable = self.render_str(
renderable, highlight=_options.highlight, markup=_options.markup
Expand Down
2 changes: 1 addition & 1 deletion rich/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def display(segments: Iterable[Segment], text: str) -> None:
try:
from IPython.display import display as ipython_display

ipython_display(jupyter_renderable)
ipython_display(jupyter_renderable) # type: ignore[no-untyped-call]
except ModuleNotFoundError:
# Handle the case where the Console has force_jupyter=True,
# but IPython is not installed.
Expand Down
2 changes: 1 addition & 1 deletion rich/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def refresh(self) -> None:
else:
if self.ipy_widget is None:
self.ipy_widget = Output()
display(self.ipy_widget)
display(self.ipy_widget) # type: ignore[no-untyped-call]

with self.ipy_widget:
self.ipy_widget.clear_output(wait=True)
Expand Down
10 changes: 5 additions & 5 deletions rich/padding.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import cast, List, Optional, Tuple, TYPE_CHECKING, Union
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

if TYPE_CHECKING:
from .console import (
Expand All @@ -7,11 +7,11 @@
RenderableType,
RenderResult,
)

from .jupyter import JupyterMixin
from .measure import Measurement
from .style import Style
from .segment import Segment

from .style import Style

PaddingDimensions = Union[int, Tuple[int], Tuple[int, int], Tuple[int, int, int, int]]

Expand Down Expand Up @@ -66,10 +66,10 @@ def unpack(pad: "PaddingDimensions") -> Tuple[int, int, int, int]:
_pad = pad[0]
return (_pad, _pad, _pad, _pad)
if len(pad) == 2:
pad_top, pad_right = cast(Tuple[int, int], pad)
pad_top, pad_right = pad
return (pad_top, pad_right, pad_top, pad_right)
if len(pad) == 4:
top, right, bottom, left = cast(Tuple[int, int, int, int], pad)
top, right, bottom, left = pad
return (top, right, bottom, left)
raise ValueError(f"1, 2 or 4 integers required for padding; {len(pad)} given")

Expand Down
2 changes: 1 addition & 1 deletion rich/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def display_hook(value: Any) -> None:
else:
from IPython.core.formatters import BaseFormatter

class RichFormatter(BaseFormatter): # type: ignore[misc]
class RichFormatter(BaseFormatter):
pprint: bool = True

def __call__(self, value: Any) -> Any:
Expand Down
3 changes: 3 additions & 0 deletions rich/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ def tell(self) -> int:
def write(self, s: Any) -> int:
raise UnsupportedOperation("write")

def writelines(self, lines: Iterable[Any]) -> None:
raise UnsupportedOperation("writelines")


class _ReadContext(ContextManager[_I], Generic[_I]):
"""A utility class to handle a context for both a reader and a progress."""
Expand Down
2 changes: 1 addition & 1 deletion rich/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def divide(
while True:
cut = next(iter_cuts, -1)
if cut == -1:
return []
return
if cut != 0:
break
yield []
Expand Down

0 comments on commit 45b7cef

Please sign in to comment.