We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] Rich's IPython extension doesn't work
**Describe the bug**

When trying to use `%load_ext rich` in **IPython** on Terminal it says following:
```
%Python 3.10.3 (main, Mar 17 2022, 04:46:20) [Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d7
Type 'copyright', 'credits' or 'license' for more information
IPython 8.1.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %load_ext rich
The rich module is not an IPython extension.
```

**Platform**
<details>
<summary>Click to expand</summary>

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.

If you're using Rich in a terminal:

```
python -m rich.diagnose
pip freeze | grep rich
```

If you're using Rich in a Jupyter Notebook, run the following snippet in a cell
and paste the output in your bug report.

```python
from rich.diagnose import report
report()
```

</details>

```
❯ python -m rich.diagnose
pip freeze | grep rich
╭────────────────── <class 'rich.console.Console'> ──────────────────╮
│ A high level console interface.                                    │
│                                                                    │
│ ╭────────────────────────────────────────────────────────────────╮ │
│ │ <console width=70 ColorSystem.TRUECOLOR>                       │ │
│ ╰────────────────────────────────────────────────────────────────╯ │
│                                                                    │
│     color_system = 'truecolor'                                     │
│         encoding = 'utf-8'                                         │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w'     │
│                    encoding='utf-8'>                               │
│           height = 45                                              │
│    is_alt_screen = False                                           │
│ is_dumb_terminal = False                                           │
│   is_interactive = True                                            │
│       is_jupyter = False                                           │
│      is_terminal = True                                            │
│   legacy_windows = False                                           │
│         no_color = False                                           │
│          options = ConsoleOptions(                                 │
│                        size=ConsoleDimensions(                     │
│                            width=70,                               │
│                            height=45                               │
│                        ),                                          │
│                        legacy_windows=False,                       │
│                        min_width=1,                                │
│                        max_width=70,                               │
│                        is_terminal=True,                           │
│                        encoding='utf-8',                           │
│                        max_height=45,                              │
│                        justify=None,                               │
│                        overflow=None,                              │
│                        no_wrap=False,                              │
│                        highlight=None,                             │
│                        markup=None,                                │
│                        height=None                                 │
│                    )                                               │
│            quiet = False                                           │
│           record = False                                           │
│         safe_box = True                                            │
│             size = ConsoleDimensions(width=70, height=45)          │
│        soft_wrap = False                                           │
│           stderr = False                                           │
│            style = None                                            │
│         tab_size = 8                                               │
│            width = 70                                              │
╰────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ {                                  │
│     'TERM': 'xterm-256color',      │
│     'COLORTERM': 'truecolor',      │
│     'CLICOLOR': None,              │
│     'NO_COLOR': None,              │
│     'TERM_PROGRAM': None,          │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JPY_PARENT_PID': None,        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯
platform="Linux"
rich @ file:///storage/emulated/0/Projects/rich
```

[![asciicast](https://asciinema.org/a/Xd3qDv897tjdEll0csW5XZk0T.svg)](https://asciinema.org/a/Xd3qDv897tjdEll0csW5XZk0T)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rich/__init__.py`
Content:
```
1 """Rich text and beautiful formatting in the terminal."""
2 
3 import os
4 from typing import Callable, IO, TYPE_CHECKING, Any, Optional, Union
5 
6 
7 __all__ = ["get_console", "reconfigure", "print", "inspect"]
8 
9 if TYPE_CHECKING:
10     from .console import Console
11 
12 # Global console used by alternative print
13 _console: Optional["Console"] = None
14 
15 _IMPORT_CWD = os.path.abspath(os.getcwd())
16 
17 
18 def get_console() -> "Console":
19     """Get a global :class:`~rich.console.Console` instance. This function is used when Rich requires a Console,
20     and hasn't been explicitly given one.
21 
22     Returns:
23         Console: A console instance.
24     """
25     global _console
26     if _console is None:
27         from .console import Console
28 
29         _console = Console()
30 
31     return _console
32 
33 
34 def reconfigure(*args: Any, **kwargs: Any) -> None:
35     """Reconfigures the global console by replacing it with another.
36 
37     Args:
38         console (Console): Replacement console instance.
39     """
40     from rich.console import Console
41 
42     new_console = Console(*args, **kwargs)
43     _console = get_console()
44     _console.__dict__ = new_console.__dict__
45 
46 
47 def print(
48     *objects: Any,
49     sep: str = " ",
50     end: str = "\n",
51     file: Optional[IO[str]] = None,
52     flush: bool = False,
53 ) -> None:
54     r"""Print object(s) supplied via positional arguments.
55     This function has an identical signature to the built-in print.
56     For more advanced features, see the :class:`~rich.console.Console` class.
57 
58     Args:
59         sep (str, optional): Separator between printed objects. Defaults to " ".
60         end (str, optional): Character to write at end of output. Defaults to "\\n".
61         file (IO[str], optional): File to write to, or None for stdout. Defaults to None.
62         flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False.
63 
64     """
65     from .console import Console
66 
67     write_console = get_console() if file is None else Console(file=file)
68     return write_console.print(*objects, sep=sep, end=end)
69 
70 
71 def print_json(
72     json: Optional[str] = None,
73     *,
74     data: Any = None,
75     indent: Union[None, int, str] = 2,
76     highlight: bool = True,
77     skip_keys: bool = False,
78     ensure_ascii: bool = True,
79     check_circular: bool = True,
80     allow_nan: bool = True,
81     default: Optional[Callable[[Any], Any]] = None,
82     sort_keys: bool = False,
83 ) -> None:
84     """Pretty prints JSON. Output will be valid JSON.
85 
86     Args:
87         json (str): A string containing JSON.
88         data (Any): If json is not supplied, then encode this data.
89         indent (int, optional): Number of spaces to indent. Defaults to 2.
90         highlight (bool, optional): Enable highlighting of output: Defaults to True.
91         skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.
92         ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.
93         check_circular (bool, optional): Check for circular references. Defaults to True.
94         allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.
95         default (Callable, optional): A callable that converts values that can not be encoded
96             in to something that can be JSON encoded. Defaults to None.
97         sort_keys (bool, optional): Sort dictionary keys. Defaults to False.
98     """
99 
100     get_console().print_json(
101         json,
102         data=data,
103         indent=indent,
104         highlight=highlight,
105         skip_keys=skip_keys,
106         ensure_ascii=ensure_ascii,
107         check_circular=check_circular,
108         allow_nan=allow_nan,
109         default=default,
110         sort_keys=sort_keys,
111     )
112 
113 
114 def inspect(
115     obj: Any,
116     *,
117     console: Optional["Console"] = None,
118     title: Optional[str] = None,
119     help: bool = False,
120     methods: bool = False,
121     docs: bool = True,
122     private: bool = False,
123     dunder: bool = False,
124     sort: bool = True,
125     all: bool = False,
126     value: bool = True,
127 ) -> None:
128     """Inspect any Python object.
129 
130     * inspect(<OBJECT>) to see summarized info.
131     * inspect(<OBJECT>, methods=True) to see methods.
132     * inspect(<OBJECT>, help=True) to see full (non-abbreviated) help.
133     * inspect(<OBJECT>, private=True) to see private attributes (single underscore).
134     * inspect(<OBJECT>, dunder=True) to see attributes beginning with double underscore.
135     * inspect(<OBJECT>, all=True) to see all attributes.
136 
137     Args:
138         obj (Any): An object to inspect.
139         title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
140         help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
141         methods (bool, optional): Enable inspection of callables. Defaults to False.
142         docs (bool, optional): Also render doc strings. Defaults to True.
143         private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
144         dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
145         sort (bool, optional): Sort attributes alphabetically. Defaults to True.
146         all (bool, optional): Show all attributes. Defaults to False.
147         value (bool, optional): Pretty print value. Defaults to True.
148     """
149     _console = console or get_console()
150     from rich._inspect import Inspect
151 
152     # Special case for inspect(inspect)
153     is_inspect = obj is inspect
154 
155     _inspect = Inspect(
156         obj,
157         title=title,
158         help=is_inspect or help,
159         methods=is_inspect or methods,
160         docs=is_inspect or docs,
161         private=private,
162         dunder=dunder,
163         sort=sort,
164         all=all,
165         value=value,
166     )
167     _console.print(_inspect)
168 
169 
170 if __name__ == "__main__":  # pragma: no cover
171     print("Hello, **World**")
172
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/rich/__init__.py b/rich/__init__.py
--- a/rich/__init__.py
+++ b/rich/__init__.py
@@ -3,6 +3,7 @@
 import os
 from typing import Callable, IO, TYPE_CHECKING, Any, Optional, Union
 
+from ._extension import load_ipython_extension
 
 __all__ = ["get_console", "reconfigure", "print", "inspect"]

{"golden_diff": "diff --git a/rich/__init__.py b/rich/__init__.py\n--- a/rich/__init__.py\n+++ b/rich/__init__.py\n@@ -3,6 +3,7 @@\n import os\n from typing import Callable, IO, TYPE_CHECKING, Any, Optional, Union\n \n+from ._extension import load_ipython_extension\n \n __all__ = [\"get_console\", \"reconfigure\", \"print\", \"inspect\"]\n", "issue": "[BUG] Rich's IPython extension doesn't work\n**Describe the bug**\r\n\r\nWhen trying to use `%load_ext rich` in **IPython** on Terminal it says following:\r\n```\r\n%Python 3.10.3 (main, Mar 17 2022, 04:46:20) [Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d7\r\nType 'copyright', 'credits' or 'license' for more information\r\nIPython 8.1.1 -- An enhanced Interactive Python. Type '?' for help.\r\n\r\nIn [1]: %load_ext rich\r\nThe rich module is not an IPython extension.\r\n```\r\n\r\n**Platform**\r\n<details>\r\n<summary>Click to expand</summary>\r\n\r\nWhat platform (Win/Linux/Mac) are you running on? What terminal software are you using?\r\n\r\nI may ask you to copy and paste the output of the following commands. It may save some time if you do it now.\r\n\r\nIf you're using Rich in a terminal:\r\n\r\n```\r\npython -m rich.diagnose\r\npip freeze | grep rich\r\n```\r\n\r\nIf you're using Rich in a Jupyter Notebook, run the following snippet in a cell\r\nand paste the output in your bug report.\r\n\r\n```python\r\nfrom rich.diagnose import report\r\nreport()\r\n```\r\n\r\n</details>\r\n\r\n```\r\n\u276f python -m rich.diagnose\r\npip freeze | grep rich\r\n\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 <class 'rich.console.Console'> \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\r\n\u2502 A high level console interface.                                    \u2502\r\n\u2502                                                                    \u2502\r\n\u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e \u2502\r\n\u2502 \u2502 <console width=70 ColorSystem.TRUECOLOR>                       \u2502 \u2502\r\n\u2502 \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502\r\n\u2502                                                                    \u2502\r\n\u2502     color_system = 'truecolor'                                     \u2502\r\n\u2502         encoding = 'utf-8'                                         \u2502\r\n\u2502             file = <_io.TextIOWrapper name='<stdout>' mode='w'     \u2502\r\n\u2502                    encoding='utf-8'>                               \u2502\r\n\u2502           height = 45                                              \u2502\r\n\u2502    is_alt_screen = False                                           \u2502\r\n\u2502 is_dumb_terminal = False                                           \u2502\r\n\u2502   is_interactive = True                                            \u2502\r\n\u2502       is_jupyter = False                                           \u2502\r\n\u2502      is_terminal = True                                            \u2502\r\n\u2502   legacy_windows = False                                           \u2502\r\n\u2502         no_color = False                                           \u2502\r\n\u2502          options = ConsoleOptions(                                 \u2502\r\n\u2502                        size=ConsoleDimensions(                     \u2502\r\n\u2502                            width=70,                               \u2502\r\n\u2502                            height=45                               \u2502\r\n\u2502                        ),                                          \u2502\r\n\u2502                        legacy_windows=False,                       \u2502\r\n\u2502                        min_width=1,                                \u2502\r\n\u2502                        max_width=70,                               \u2502\r\n\u2502                        is_terminal=True,                           \u2502\r\n\u2502                        encoding='utf-8',                           \u2502\r\n\u2502                        max_height=45,                              \u2502\r\n\u2502                        justify=None,                               \u2502\r\n\u2502                        overflow=None,                              \u2502\r\n\u2502                        no_wrap=False,                              \u2502\r\n\u2502                        highlight=None,                             \u2502\r\n\u2502                        markup=None,                                \u2502\r\n\u2502                        height=None                                 \u2502\r\n\u2502                    )                                               \u2502\r\n\u2502            quiet = False                                           \u2502\r\n\u2502           record = False                                           \u2502\r\n\u2502         safe_box = True                                            \u2502\r\n\u2502             size = ConsoleDimensions(width=70, height=45)          \u2502\r\n\u2502        soft_wrap = False                                           \u2502\r\n\u2502           stderr = False                                           \u2502\r\n\u2502            style = None                                            \u2502\r\n\u2502         tab_size = 8                                               \u2502\r\n\u2502            width = 70                                              \u2502\r\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\r\n\u256d\u2500\u2500\u2500 <class 'rich._windows.WindowsConsoleFeatures'> \u2500\u2500\u2500\u2500\u256e\r\n\u2502 Windows features available.                           \u2502\r\n\u2502                                                       \u2502\r\n\u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e \u2502\r\n\u2502 \u2502 WindowsConsoleFeatures(vt=False, truecolor=False) \u2502 \u2502\r\n\u2502 \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502\r\n\u2502                                                       \u2502\r\n\u2502 truecolor = False                                     \u2502\r\n\u2502        vt = False                                     \u2502\r\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\r\n\u256d\u2500\u2500\u2500\u2500\u2500\u2500 Environment Variables \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\r\n\u2502 {                                  \u2502\r\n\u2502     'TERM': 'xterm-256color',      \u2502\r\n\u2502     'COLORTERM': 'truecolor',      \u2502\r\n\u2502     'CLICOLOR': None,              \u2502\r\n\u2502     'NO_COLOR': None,              \u2502\r\n\u2502     'TERM_PROGRAM': None,          \u2502\r\n\u2502     'COLUMNS': None,               \u2502\r\n\u2502     'LINES': None,                 \u2502\r\n\u2502     'JPY_PARENT_PID': None,        \u2502\r\n\u2502     'VSCODE_VERBOSE_LOGGING': None \u2502\r\n\u2502 }                                  \u2502\r\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\r\nplatform=\"Linux\"\r\nrich @ file:///storage/emulated/0/Projects/rich\r\n```\r\n\r\n[![asciicast](https://asciinema.org/a/Xd3qDv897tjdEll0csW5XZk0T.svg)](https://asciinema.org/a/Xd3qDv897tjdEll0csW5XZk0T)\n", "before_files": [{"content": "\"\"\"Rich text and beautiful formatting in the terminal.\"\"\"\n\nimport os\nfrom typing import Callable, IO, TYPE_CHECKING, Any, Optional, Union\n\n\n__all__ = [\"get_console\", \"reconfigure\", \"print\", \"inspect\"]\n\nif TYPE_CHECKING:\n    from .console import Console\n\n# Global console used by alternative print\n_console: Optional[\"Console\"] = None\n\n_IMPORT_CWD = os.path.abspath(os.getcwd())\n\n\ndef get_console() -> \"Console\":\n    \"\"\"Get a global :class:`~rich.console.Console` instance. This function is used when Rich requires a Console,\n    and hasn't been explicitly given one.\n\n    Returns:\n        Console: A console instance.\n    \"\"\"\n    global _console\n    if _console is None:\n        from .console import Console\n\n        _console = Console()\n\n    return _console\n\n\ndef reconfigure(*args: Any, **kwargs: Any) -> None:\n    \"\"\"Reconfigures the global console by replacing it with another.\n\n    Args:\n        console (Console): Replacement console instance.\n    \"\"\"\n    from rich.console import Console\n\n    new_console = Console(*args, **kwargs)\n    _console = get_console()\n    _console.__dict__ = new_console.__dict__\n\n\ndef print(\n    *objects: Any,\n    sep: str = \" \",\n    end: str = \"\\n\",\n    file: Optional[IO[str]] = None,\n    flush: bool = False,\n) -> None:\n    r\"\"\"Print object(s) supplied via positional arguments.\n    This function has an identical signature to the built-in print.\n    For more advanced features, see the :class:`~rich.console.Console` class.\n\n    Args:\n        sep (str, optional): Separator between printed objects. Defaults to \" \".\n        end (str, optional): Character to write at end of output. Defaults to \"\\\\n\".\n        file (IO[str], optional): File to write to, or None for stdout. Defaults to None.\n        flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False.\n\n    \"\"\"\n    from .console import Console\n\n    write_console = get_console() if file is None else Console(file=file)\n    return write_console.print(*objects, sep=sep, end=end)\n\n\ndef print_json(\n    json: Optional[str] = None,\n    *,\n    data: Any = None,\n    indent: Union[None, int, str] = 2,\n    highlight: bool = True,\n    skip_keys: bool = False,\n    ensure_ascii: bool = True,\n    check_circular: bool = True,\n    allow_nan: bool = True,\n    default: Optional[Callable[[Any], Any]] = None,\n    sort_keys: bool = False,\n) -> None:\n    \"\"\"Pretty prints JSON. Output will be valid JSON.\n\n    Args:\n        json (str): A string containing JSON.\n        data (Any): If json is not supplied, then encode this data.\n        indent (int, optional): Number of spaces to indent. Defaults to 2.\n        highlight (bool, optional): Enable highlighting of output: Defaults to True.\n        skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.\n        ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.\n        check_circular (bool, optional): Check for circular references. Defaults to True.\n        allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.\n        default (Callable, optional): A callable that converts values that can not be encoded\n            in to something that can be JSON encoded. Defaults to None.\n        sort_keys (bool, optional): Sort dictionary keys. Defaults to False.\n    \"\"\"\n\n    get_console().print_json(\n        json,\n        data=data,\n        indent=indent,\n        highlight=highlight,\n        skip_keys=skip_keys,\n        ensure_ascii=ensure_ascii,\n        check_circular=check_circular,\n        allow_nan=allow_nan,\n        default=default,\n        sort_keys=sort_keys,\n    )\n\n\ndef inspect(\n    obj: Any,\n    *,\n    console: Optional[\"Console\"] = None,\n    title: Optional[str] = None,\n    help: bool = False,\n    methods: bool = False,\n    docs: bool = True,\n    private: bool = False,\n    dunder: bool = False,\n    sort: bool = True,\n    all: bool = False,\n    value: bool = True,\n) -> None:\n    \"\"\"Inspect any Python object.\n\n    * inspect(<OBJECT>) to see summarized info.\n    * inspect(<OBJECT>, methods=True) to see methods.\n    * inspect(<OBJECT>, help=True) to see full (non-abbreviated) help.\n    * inspect(<OBJECT>, private=True) to see private attributes (single underscore).\n    * inspect(<OBJECT>, dunder=True) to see attributes beginning with double underscore.\n    * inspect(<OBJECT>, all=True) to see all attributes.\n\n    Args:\n        obj (Any): An object to inspect.\n        title (str, optional): Title to display over inspect result, or None use type. Defaults to None.\n        help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.\n        methods (bool, optional): Enable inspection of callables. Defaults to False.\n        docs (bool, optional): Also render doc strings. Defaults to True.\n        private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.\n        dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.\n        sort (bool, optional): Sort attributes alphabetically. Defaults to True.\n        all (bool, optional): Show all attributes. Defaults to False.\n        value (bool, optional): Pretty print value. Defaults to True.\n    \"\"\"\n    _console = console or get_console()\n    from rich._inspect import Inspect\n\n    # Special case for inspect(inspect)\n    is_inspect = obj is inspect\n\n    _inspect = Inspect(\n        obj,\n        title=title,\n        help=is_inspect or help,\n        methods=is_inspect or methods,\n        docs=is_inspect or docs,\n        private=private,\n        dunder=dunder,\n        sort=sort,\n        all=all,\n        value=value,\n    )\n    _console.print(_inspect)\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    print(\"Hello, **World**\")\n", "path": "rich/__init__.py"}], "after_files": [{"content": "\"\"\"Rich text and beautiful formatting in the terminal.\"\"\"\n\nimport os\nfrom typing import Callable, IO, TYPE_CHECKING, Any, Optional, Union\n\nfrom ._extension import load_ipython_extension\n\n__all__ = [\"get_console\", \"reconfigure\", \"print\", \"inspect\"]\n\nif TYPE_CHECKING:\n    from .console import Console\n\n# Global console used by alternative print\n_console: Optional[\"Console\"] = None\n\n_IMPORT_CWD = os.path.abspath(os.getcwd())\n\n\ndef get_console() -> \"Console\":\n    \"\"\"Get a global :class:`~rich.console.Console` instance. This function is used when Rich requires a Console,\n    and hasn't been explicitly given one.\n\n    Returns:\n        Console: A console instance.\n    \"\"\"\n    global _console\n    if _console is None:\n        from .console import Console\n\n        _console = Console()\n\n    return _console\n\n\ndef reconfigure(*args: Any, **kwargs: Any) -> None:\n    \"\"\"Reconfigures the global console by replacing it with another.\n\n    Args:\n        console (Console): Replacement console instance.\n    \"\"\"\n    from rich.console import Console\n\n    new_console = Console(*args, **kwargs)\n    _console = get_console()\n    _console.__dict__ = new_console.__dict__\n\n\ndef print(\n    *objects: Any,\n    sep: str = \" \",\n    end: str = \"\\n\",\n    file: Optional[IO[str]] = None,\n    flush: bool = False,\n) -> None:\n    r\"\"\"Print object(s) supplied via positional arguments.\n    This function has an identical signature to the built-in print.\n    For more advanced features, see the :class:`~rich.console.Console` class.\n\n    Args:\n        sep (str, optional): Separator between printed objects. Defaults to \" \".\n        end (str, optional): Character to write at end of output. Defaults to \"\\\\n\".\n        file (IO[str], optional): File to write to, or None for stdout. Defaults to None.\n        flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False.\n\n    \"\"\"\n    from .console import Console\n\n    write_console = get_console() if file is None else Console(file=file)\n    return write_console.print(*objects, sep=sep, end=end)\n\n\ndef print_json(\n    json: Optional[str] = None,\n    *,\n    data: Any = None,\n    indent: Union[None, int, str] = 2,\n    highlight: bool = True,\n    skip_keys: bool = False,\n    ensure_ascii: bool = True,\n    check_circular: bool = True,\n    allow_nan: bool = True,\n    default: Optional[Callable[[Any], Any]] = None,\n    sort_keys: bool = False,\n) -> None:\n    \"\"\"Pretty prints JSON. Output will be valid JSON.\n\n    Args:\n        json (str): A string containing JSON.\n        data (Any): If json is not supplied, then encode this data.\n        indent (int, optional): Number of spaces to indent. Defaults to 2.\n        highlight (bool, optional): Enable highlighting of output: Defaults to True.\n        skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.\n        ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.\n        check_circular (bool, optional): Check for circular references. Defaults to True.\n        allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.\n        default (Callable, optional): A callable that converts values that can not be encoded\n            in to something that can be JSON encoded. Defaults to None.\n        sort_keys (bool, optional): Sort dictionary keys. Defaults to False.\n    \"\"\"\n\n    get_console().print_json(\n        json,\n        data=data,\n        indent=indent,\n        highlight=highlight,\n        skip_keys=skip_keys,\n        ensure_ascii=ensure_ascii,\n        check_circular=check_circular,\n        allow_nan=allow_nan,\n        default=default,\n        sort_keys=sort_keys,\n    )\n\n\ndef inspect(\n    obj: Any,\n    *,\n    console: Optional[\"Console\"] = None,\n    title: Optional[str] = None,\n    help: bool = False,\n    methods: bool = False,\n    docs: bool = True,\n    private: bool = False,\n    dunder: bool = False,\n    sort: bool = True,\n    all: bool = False,\n    value: bool = True,\n) -> None:\n    \"\"\"Inspect any Python object.\n\n    * inspect(<OBJECT>) to see summarized info.\n    * inspect(<OBJECT>, methods=True) to see methods.\n    * inspect(<OBJECT>, help=True) to see full (non-abbreviated) help.\n    * inspect(<OBJECT>, private=True) to see private attributes (single underscore).\n    * inspect(<OBJECT>, dunder=True) to see attributes beginning with double underscore.\n    * inspect(<OBJECT>, all=True) to see all attributes.\n\n    Args:\n        obj (Any): An object to inspect.\n        title (str, optional): Title to display over inspect result, or None use type. Defaults to None.\n        help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.\n        methods (bool, optional): Enable inspection of callables. Defaults to False.\n        docs (bool, optional): Also render doc strings. Defaults to True.\n        private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.\n        dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.\n        sort (bool, optional): Sort attributes alphabetically. Defaults to True.\n        all (bool, optional): Show all attributes. Defaults to False.\n        value (bool, optional): Pretty print value. Defaults to True.\n    \"\"\"\n    _console = console or get_console()\n    from rich._inspect import Inspect\n\n    # Special case for inspect(inspect)\n    is_inspect = obj is inspect\n\n    _inspect = Inspect(\n        obj,\n        title=title,\n        help=is_inspect or help,\n        methods=is_inspect or methods,\n        docs=is_inspect or docs,\n        private=private,\n        dunder=dunder,\n        sort=sort,\n        all=all,\n        value=value,\n    )\n    _console.print(_inspect)\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    print(\"Hello, **World**\")\n", "path": "rich/__init__.py"}]}