Skip to content

Commit 25ef1c2

Browse files
authored
Fix test import and address pre-commit checks (#2)
* Fix import in test_utils * Tweak readme
1 parent c66c7fc commit 25ef1c2

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ task_queue = AsyncTaskQueue(
5151
# Add async tasks to the queue
5252
task_queue.enqueue(
5353
[
54-
AsyncTask(some_coroutine, arg) for arg in some_args
54+
AsyncTask(some_coroutine, *args, **kwargs) for args, kwargs in some_args_kwargs
5555
]
5656
)
5757

src/async_task_queue/async_task_queue.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async def execute(self) -> None:
2626
self.result = e
2727

2828
def __repr__(self) -> str:
29+
"""Object representation for debugging"""
2930
return render(self, treelike_whitelist=(AsyncTask,))
3031

3132

@@ -259,4 +260,5 @@ async def _execute_task(self, task: AsyncTask, queue: deque) -> None:
259260
self._enqueue([task], queue=self.succeeded_tasks)
260261

261262
def __repr__(self) -> str:
263+
"""Object representation for debugging"""
262264
return render(self, treelike_whitelist=(AsyncTaskQueue,))

src/async_task_queue/render.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
"""Module for rendering output of python objects"""
2+
13
import inspect
24
from typing import Any, Callable, Dict, Set, Tuple, Type
35
from unittest.mock import Mock
46

5-
67
COLOR_CODES = {
78
"blue": "\033[94m",
89
"green": "\033[92m",
@@ -81,7 +82,8 @@ def _render(
8182
level: The level in the tree at which the `obj` is rendered.
8283
indent: What represents a single indentation.
8384
treelike_whitelist: Classes to render in a tree-like fashion.
84-
attr_blacklist: attributes to exclude
85+
treelike_blacklist: Classes to render with the typename only.
86+
attr_blacklist: Attributes to exclude from rendering
8587
renderer_overrides: a mapping from classes to functions that should be used
8688
to render those classes. The function should take an instance of the class
8789
and return the rendered string
@@ -166,6 +168,7 @@ def _get_default_arguments(obj: Any) -> Set[str]:
166168
167169
Returns:
168170
the set of default arguments
171+
169172
"""
170173
cls = type(obj)
171174
obj_sig = inspect.signature(cls.__init__)
@@ -200,7 +203,6 @@ def render(
200203
"""Render any object in tree form.
201204
202205
Example:
203-
204206
Class(
205207
arg1=val1,
206208
arg2=[
@@ -217,8 +219,8 @@ def render(
217219
indent: What represents a single indentation.
218220
treelike_whitelist: Classes to render in a tree-like fashion.
219221
treelike_blacklist: Classes to render with the typename only.
220-
attr_blacklist: attributes to exclude
221-
renderer_overrides: a mapping from classes to functions that should be used
222+
attr_blacklist: Attributes to exclude from rendering
223+
renderer_overrides: A mapping from classes to functions that should be used
222224
to render those classes. The function should take an instance of the class
223225
and return the rendered string
224226

tests/test_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Contains test utilities"""
22

33
import asyncio
4-
from typing import Any, Callable
4+
from typing import Callable
5+
from unittest.mock import MagicMock
56

67

78
def async_test(async_test_func: Callable[..., None]) -> Callable[..., None]:

0 commit comments

Comments
 (0)