2
2
==========
3
3
"""
4
4
5
- from typing import Any , Callable
5
+ from collections .abc import Callable
6
+ from typing import Any
6
7
7
8
from IPython .terminal .interactiveshell import TerminalInteractiveShell
8
9
from IPython .terminal .prompts import ClassicPrompts , Prompts
@@ -16,7 +17,7 @@ def get_new_prompts_class(
16
17
prompts_class : type ,
17
18
hook : Callable = wakatime_hook ,
18
19
args : tuple = (),
19
- kwargs : dict [str , Any ] = {} ,
20
+ kwargs : dict [str , Any ] | None = None ,
20
21
) -> type :
21
22
"""Get new prompts class.
22
23
@@ -27,9 +28,11 @@ def get_new_prompts_class(
27
28
:param args:
28
29
:type args: tuple
29
30
:param kwargs:
30
- :type kwargs: dict[str, Any]
31
+ :type kwargs: dict[str, Any] | None
31
32
:rtype: type
32
33
"""
34
+ if kwargs is None :
35
+ kwargs = {}
33
36
if isinstance (prompts_class , LazyConfigValue ):
34
37
prompts_class = ClassicPrompts
35
38
shell = TerminalInteractiveShell ()
@@ -77,7 +80,7 @@ def install_hook(
77
80
c : Config ,
78
81
hook : Callable = wakatime_hook ,
79
82
args : tuple = (),
80
- kwargs : dict [str , Any ] = { "plugin" : "repl-ipython-wakatime" } ,
83
+ kwargs : dict [str , Any ] | None = None ,
81
84
) -> Config :
82
85
"""Install hook.
83
86
@@ -88,10 +91,15 @@ def install_hook(
88
91
:param args:
89
92
:type args: tuple
90
93
:param kwargs:
91
- :type kwargs: dict[str, Any]
94
+ :type kwargs: dict[str, Any] | None
92
95
:rtype: Config
93
96
"""
97
+ if kwargs is None :
98
+ kwargs = {"plugin" : "repl-ipython-wakatime" }
94
99
c .TerminalInteractiveShell .prompts_class = get_new_prompts_class ( # type: ignore
95
- c .TerminalInteractiveShell .prompts_class , hook , args , kwargs # type: ignore
100
+ c .TerminalInteractiveShell .prompts_class ,
101
+ hook ,
102
+ args ,
103
+ kwargs , # type: ignore
96
104
)
97
105
return c
0 commit comments