Skip to content

Commit 3bc573a

Browse files
committed
fix: correcting bug and isort
1 parent 539479f commit 3bc573a

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "moodle-painkillers"
3-
version = "1.0.6"
3+
version = "1.0.7"
44
description = "Signs you up on Moodle so you get paid."
55
readme = "README.md"
66
requires-python = ">=3.12"

src/moodle_painkillers/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import argparse
22
import logging
33
import os
4+
from ast import ParamSpec, TypeVar
45
from dataclasses import dataclass
5-
from typing import Any, Callable
6+
from typing import Callable
67

78
import bs4
89
import requests as rq
910

10-
from .notifications import send_notification
1111
from .moodle_authenticate import MoodleAuthenticatedSession
12+
from .notifications import send_notification
1213

1314
log = logging.getLogger(__name__)
1415

@@ -153,7 +154,7 @@ def parse_args():
153154
)
154155

155156

156-
def notify_on_fail(func: Callable[[Any], Any]):
157+
def notify_on_fail[R](func: Callable[..., R]) -> Callable[..., R]:
157158
"""
158159
Decorator to send a notification in case of failure.
159160
@@ -164,7 +165,7 @@ def notify_on_fail(func: Callable[[Any], Any]):
164165
callable: The decorated function.
165166
"""
166167

167-
def wrapper(*args, **kwargs):
168+
def wrapper(*args: object, **kwargs: object):
168169
try:
169170
return func(*args, **kwargs)
170171
except Exception as e:
@@ -212,11 +213,13 @@ def main() -> None:
212213

213214
log.info("Presence registration process completed successfully")
214215
_ = send_notification(
215-
"Sent presence status!", discord_webhook=args.discord_webhook
216+
"Sent presence status!",
217+
title=NOTIFICATION_TITLE,
218+
discord_webhook=args.discord_webhook,
216219
)
217220

218221
return
219222

220223

221-
if __name__ == "__main__":
224+
if __name__ == "__main__": # pragma: no cover
222225
main()

src/moodle_painkillers/notifications/linux.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import subprocess
21
import shutil
2+
import subprocess
33
from logging import getLogger
44

55
log = getLogger(__name__)

tests/test___init__.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
import pytest
66
import requests as rq
77

8-
from moodle_painkillers import (
9-
main,
10-
notify_on_fail,
11-
parse_args,
12-
register_presence_status,
13-
)
8+
from moodle_painkillers import (main, notify_on_fail, parse_args,
9+
register_presence_status)
1410

1511

1612
class TestRegisterPresenceStatus:
@@ -244,7 +240,9 @@ def failing_func():
244240
assert excinfo.value == test_exception
245241

246242
# Verify send_notification was called with the exception message
247-
mock_send_notification.assert_called_once_with('test error', title='Moodle Presence Registration')
243+
mock_send_notification.assert_called_once_with(
244+
"test error", title="Moodle Presence Registration"
245+
)
248246

249247
@patch("moodle_painkillers.send_notification")
250248
def test_with_arguments(self, mock_send_notification):
@@ -294,7 +292,9 @@ def test_main_successful_workflow(
294292
mock_session_class.assert_called_once_with("test_user", "test_pass")
295293
mock_register_presence.assert_called_once_with(mock_session)
296294
mock_send_notification.assert_called_once_with(
297-
"Sent presence status!", discord_webhook="test_webhook"
295+
"Sent presence status!",
296+
title="Moodle Presence Registration",
297+
discord_webhook="test_webhook",
298298
)
299299

300300
@patch("moodle_painkillers.send_notification")
@@ -324,7 +324,9 @@ def test_main_without_webhook(
324324

325325
# Verify notification called with None webhook
326326
mock_send_notification.assert_called_once_with(
327-
"Sent presence status!", discord_webhook=None
327+
"Sent presence status!",
328+
title="Moodle Presence Registration",
329+
discord_webhook=None,
328330
)
329331

330332
@patch("moodle_painkillers.register_presence_status")

tests/test_moodle_authenticate.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
import pytest
33
import requests
44

5-
from moodle_painkillers.moodle_authenticate import (
6-
MoodleAuthenticatedSession,
7-
get_hidden_input_value,
8-
)
5+
from moodle_painkillers.moodle_authenticate import (MoodleAuthenticatedSession,
6+
get_hidden_input_value)
97

108

119
class TestGetHiddenInputValue:

0 commit comments

Comments
 (0)