diff --git a/rich/console.py b/rich/console.py index ef3352f3..bae2f36a 100644 --- a/rich/console.py +++ b/rich/console.py @@ -1625,7 +1625,7 @@ class Console: json: Optional[str] = None, *, data: Any = None, - indent: int = 2, + indent: Union[None, int, str] = 2, highlight: bool = True, skip_keys: bool = False, ensure_ascii: bool = True, @@ -1639,7 +1639,7 @@ class Console: Args: json (Optional[str]): A string containing JSON. data (Any): If json is not supplied, then encode this data. - indent (int, optional): Number of spaces to indent. Defaults to 2. + indent (Union[None, int, str], optional): Number of spaces to indent. Defaults to 2. highlight (bool, optional): Enable highlighting of output: Defaults to True. skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False. ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False. diff --git a/rich/json.py b/rich/json.py index 4f3199fd..1fc115a9 100644 --- a/rich/json.py +++ b/rich/json.py @@ -1,5 +1,5 @@ from json import loads, dumps -from typing import Any, Callable, Optional +from typing import Any, Callable, Optional, Union from .text import Text from .highlighter import JSONHighlighter, NullHighlighter @@ -10,7 +10,7 @@ class JSON: Args: json (str): JSON encoded data. - indent (int, optional): Number of characters to indent by. Defaults to 2. + indent (Union[None, int, str], optional): Number of characters to indent by. Defaults to 2. highlight (bool, optional): Enable highlighting. Defaults to True. skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False. ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False. @@ -24,7 +24,7 @@ class JSON: def __init__( self, json: str, - indent: int = 2, + indent: Union[None, int, str] = 2, highlight: bool = True, skip_keys: bool = False, ensure_ascii: bool = True, @@ -53,7 +53,7 @@ class JSON: def from_data( cls, data: Any, - indent: int = 2, + indent: Union[None, int, str] = 2, highlight: bool = True, skip_keys: bool = False, ensure_ascii: bool = True, @@ -66,7 +66,7 @@ class JSON: Args: data (Any): An object that may be encoded in to JSON - indent (int, optional): Number of characters to indent by. Defaults to 2. + indent (Union[None, int, str], optional): Number of characters to indent by. Defaults to 2. highlight (bool, optional): Enable highlighting. Defaults to True. default (Callable, optional): Optional callable which will be called for objects that cannot be serialized. Defaults to None. skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.