mirror of
https://github.com/Textualize/rich.git
synced 2025-08-28 14:14:18 +00:00
Update types for typechecks
This commit is contained in:
parent
a7b1518c6a
commit
fdac216130
2 changed files with 9 additions and 9 deletions
|
@ -138,8 +138,8 @@ class Table(JupyterMixin):
|
||||||
border_style: StyleType = None,
|
border_style: StyleType = None,
|
||||||
title_style: StyleType = None,
|
title_style: StyleType = None,
|
||||||
caption_style: StyleType = None,
|
caption_style: StyleType = None,
|
||||||
title_justify: str = "center",
|
title_justify: "JustifyMethod" = "center",
|
||||||
caption_justify: str = "center",
|
caption_justify: "JustifyMethod" = "center",
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
self.columns: List[Column] = []
|
self.columns: List[Column] = []
|
||||||
|
@ -387,7 +387,7 @@ class Table(JupyterMixin):
|
||||||
render_options = options.update(width=table_width)
|
render_options = options.update(width=table_width)
|
||||||
|
|
||||||
def render_annotation(
|
def render_annotation(
|
||||||
text: TextType, style: StyleType, justify: str = "center"
|
text: TextType, style: StyleType, justify: JustifyMethod = "center"
|
||||||
) -> "RenderResult":
|
) -> "RenderResult":
|
||||||
render_text = (
|
render_text = (
|
||||||
console.render_str(text, style=style) if isinstance(text, str) else text
|
console.render_str(text, style=style) if isinstance(text, str) else text
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from rich.console import JustifyMethod
|
||||||
|
|
||||||
from . import box
|
from . import box
|
||||||
from .highlighter import ReprHighlighter
|
from .highlighter import ReprHighlighter
|
||||||
from .pretty import Pretty
|
from .pretty import Pretty
|
||||||
from .table import Table
|
from .table import Table
|
||||||
|
|
||||||
_NOT_PROVIDED = object()
|
|
||||||
|
|
||||||
|
|
||||||
def tabulate_mapping(
|
def tabulate_mapping(
|
||||||
mapping: Mapping,
|
mapping: Mapping,
|
||||||
title: str = None,
|
title: str = None,
|
||||||
caption: str = None,
|
caption: str = None,
|
||||||
title_justify: str = _NOT_PROVIDED,
|
title_justify: Optional[JustifyMethod] = None,
|
||||||
caption_justify: str = _NOT_PROVIDED,
|
caption_justify: Optional[JustifyMethod] = None,
|
||||||
) -> Table:
|
) -> Table:
|
||||||
"""Generate a simple table from a mapping.
|
"""Generate a simple table from a mapping.
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ def tabulate_mapping(
|
||||||
)
|
)
|
||||||
table.title = title
|
table.title = title
|
||||||
table.caption = caption
|
table.caption = caption
|
||||||
if title_justify is not _NOT_PROVIDED:
|
if title_justify is not None:
|
||||||
table.title_justify = title_justify
|
table.title_justify = title_justify
|
||||||
if caption_justify is not _NOT_PROVIDED:
|
if caption_justify is not None:
|
||||||
table.caption_justify = caption_justify
|
table.caption_justify = caption_justify
|
||||||
highlighter = ReprHighlighter()
|
highlighter = ReprHighlighter()
|
||||||
for key, value in mapping.items():
|
for key, value in mapping.items():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue