typing, docstrings

This commit is contained in:
Will McGugan 2020-09-24 21:44:05 +01:00
parent a16a234c29
commit 65da5adf52
5 changed files with 21 additions and 6 deletions

View File

@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added Console.capture method
- Added Console.begin_capture, Console.end_capture and Console.capture
- Added Table.title_justify and Table.caption_justify https://github.com/willmcgugan/rich/issues/301
### Changed

View File

@ -205,7 +205,7 @@ class TextColumn(ProgressColumn):
self.highlighter = highlighter
super().__init__()
def render(self, task: "Task"):
def render(self, task: "Task") -> Text:
_text = self.text_format.format(task=task)
if self.markup:
text = Text.from_markup(_text, style=self.style, justify=self.justify)

View File

@ -108,8 +108,8 @@ class Table(JupyterMixin):
border_style (Union[str, Style], optional): Style of the border. Defaults to None.
title_style (Union[str, Style], optional): Style of the title. Defaults to None.
caption_style (Union[str, Style], optional): Style of the caption. Defaults to None.
title_justify (str, optional): Justification for title. Defaults to "center".
caption_justify (str, optional): Justification for caption. Defaults to "center".
title_justify (str, optional): Justify method for title. Defaults to "center".
caption_justify (str, optional): Justify method for caption. Defaults to "center".
"""
columns: List[Column]

View File

@ -22,8 +22,8 @@ def tabulate_mapping(
mapping (Mapping): A mapping object (e.g. a dict);
title (str, optional): Optional title to be displayed over the table.
caption (str, optional): Optional caption to be displayed below the table.
title_justify (str, optional): Optional "right", "center", "left" string indicating title justification
caption_justify (str, optional): Optional "right", "center", "left" string indicating caption justification
title_justify (str, optional): Justify method for title. Defaults to None.
caption_justify (str, optional): Justify method for caption. Defaults to None.
Returns:
Table: A table instance which may be rendered by the Console.

View File

@ -154,6 +154,20 @@ class Traceback:
theme: Optional[str] = None,
word_wrap: bool = False,
) -> "Traceback":
"""Create a traceback from exception info
Args:
exc_type (Type[BaseException]): Exception type.
exc_value (BaseException): Exception value.
traceback (TracebackType): Python Traceback object.
width (Optional[int], optional): Number of characters used to traceback. Defaults to 100.
extra_lines (int, optional): Additional lines of code to render. Defaults to 3.
theme (str, optional): Override pygments theme used in traceback.
word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
Returns:
Traceback: A Traceback instance that may be printed.
"""
rich_traceback = cls.extract(exc_type, exc_value, traceback)
return Traceback(
rich_traceback,