Skip to content

Commit 92f620c

Browse files
committed
Resolving issues with Python 3.7 and addressing linter warnings
1 parent 0090079 commit 92f620c

File tree

5 files changed

+8
-13
lines changed

5 files changed

+8
-13
lines changed

.editorconfig

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ insert_final_newline = true
1010
charset = utf-8
1111
end_of_line = lf
1212

13-
[*.bat]
14-
indent_style = tab
15-
end_of_line = crlf
16-
1713
[LICENSE]
1814
insert_final_newline = false
1915

dike/__init__.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import concurrent
44
import functools
55
import inspect
6-
from dataclasses import dataclass
7-
from typing import Awaitable, Callable, Dict, Iterable, List, Sequence, Tuple, Union
6+
from typing import Callable, Dict, List, Tuple
87

98

109
def wrap_in_coroutine(func: Callable) -> Callable:
@@ -31,8 +30,6 @@ async def _wrapper(*args, **kwargs):
3130
class TooManyCalls(Exception):
3231
"""Error raised by @limit_jobs when a call exceeds the preset limit"""
3332

34-
pass
35-
3633

3734
def limit_jobs(*, limit: int):
3835
"""Decorator to limit the number of concurrent calls to a coroutine function.
@@ -46,6 +43,7 @@ def limit_jobs(*, limit: int):
4643
Raises:
4744
TooManyCalls: The decorated function raises a dike.ToomanyCalls exception
4845
if it is called while already running `limit` times concurrently.
46+
ValueError: If the decorator is applied to something else than an async def function
4947
5048
Examples:
5149
>>> import asyncio
@@ -88,7 +86,7 @@ def decorator(func):
8886
async def limited_call(*args, **kwargs):
8987
nonlocal counter
9088
if counter == 0:
91-
raise TooManyCalls(f"Too many calls to {str(func)}! {limit=}")
89+
raise TooManyCalls(f"Too many calls to {str(func)}! limit={limit}")
9290
try:
9391
counter -= 1
9492
return await func(*args, **kwargs)

tests/test_batch.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
"""Tests for for the decorator dike.batch"""
12
import asyncio
2-
from typing import Dict
3-
import dike
3+
44
import pytest
55

6+
import dike
7+
68

79
async def raise_error(message):
810
raise RuntimeError(message)

tests/test_limit_jobs.py

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ async def f():
8888
@pytest.mark.parametrize("l", [-1, -1.5, float("-inf")])
8989
def test_unlogical_limits_give_clear_error(l):
9090
"""Ensure that a proper error message is shown when trying to set strange limits"""
91-
print(f"{l=}")
9291
with pytest.raises(ValueError, match=re.escape("Error when wrapping f(). Limit must be >= 0")):
9392

9493
@dike.limit_jobs(limit=l)

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ setenv =
5050
PYTHONWARNINGS = ignore
5151
allowlist_externals = pytest
5252
commands =
53-
pytest -s --cov=dike --cov-append --cov-report=xml --cov-report term-missing --junit-xml pytest.xml tests
53+
pytest -s --doctest-modules --cov=dike --cov-append --cov-report=xml --cov-report term-missing --junit-xml pytest.xml tests

0 commit comments

Comments
 (0)