Skip to content

Commit d822945

Browse files
committed
🧑‍💻 Change hook definitions
Update configure methods in README.md
1 parent e5e3275 commit d822945

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ install_hook(c)
8989
`install_hook()` must be after the customization of the prompt string and best
9090
at the end of file.
9191

92+
## Configure
93+
94+
```python
95+
from repl_python_wakatime.python import install_hook
96+
97+
install_hook(f, args, kwargs)
98+
```
99+
100+
will execute `f(*args, **kwargs)` after every output/input. Other REPLs are
101+
similar.
102+
92103
## Similar projects
93104

94105
- [wakatime plugins for python and many shells](https://wakatime.com/terminal)

src/repl_python_wakatime/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ def send_wakatime_heartbeat(
5252
)
5353

5454

55-
def wakatime_hook(args: tuple = (), kwargs: dict[str, Any] = {}) -> None:
55+
def wakatime_hook(*args: Any, **kwargs: Any) -> None:
5656
"""Wakatime hook.
5757
5858
:param args:
59-
:type args: tuple
59+
:type args: Any
60+
:param kwargs:
61+
:type kwargs: Any
6062
:rtype: None
6163
"""
6264
if which("wakatime-cli") is None:

src/repl_python_wakatime/ipython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def out_prompt_tokens(self) -> list[tuple[_TokenType, str]]:
6666
6767
:rtype: list[tuple[_TokenType, str]]
6868
"""
69-
hook(args, kwargs)
69+
hook(*args, **kwargs)
7070
return prompts_class(shell).out_prompt_tokens()
7171

7272
return Ps

src/repl_python_wakatime/ptpython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def out_prompt(self) -> AnyFormattedText:
6060
6161
:rtype: AnyFormattedText
6262
"""
63-
self.hook(self.args, self.kwargs)
63+
self.hook(*self.args, **self.kwargs)
6464
return self.prompt_style.out_prompt()
6565

6666

src/repl_python_wakatime/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __str__(self) -> str:
4545
4646
:rtype: str
4747
"""
48-
self.hook(self.args, self.kwargs)
48+
self.hook(*self.args, **self.kwargs)
4949
if isinstance(self.ps1, str):
5050
return self.ps1
5151
else:

0 commit comments

Comments
 (0)