Skip to content

Commit 748edd3

Browse files
committed
Linter fixes
1 parent a7d8522 commit 748edd3

File tree

13 files changed

+48
-49
lines changed

13 files changed

+48
-49
lines changed

aiomisc/entrypoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def _on_interrupt(self, loop: asyncio.AbstractEventLoop) -> None:
419419
handle = loop.call_later(self.shutdown_timeout, task.cancel)
420420

421421
def on_shutdown_finish(task: asyncio.Future) -> None:
422-
nonlocal handle, loop
422+
nonlocal handle, loop # noqa
423423

424424
if task.cancelled():
425425
log.warning(

aiomisc/service/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import asyncio
22
from abc import ABC, ABCMeta, abstractmethod
3-
from typing import (
4-
Any, Coroutine, Dict, Generator, Optional, Set, Tuple, TypeVar, Union,
5-
)
3+
from typing import Any, Coroutine, Dict, Optional, Set, Tuple, TypeVar, Union
64

75
from ..context import Context, get_context
86
from ..utils import cancel_tasks

aiomisc/thread_pool.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import warnings
99
from concurrent.futures import ThreadPoolExecutor as ThreadPoolExecutorBase
1010
from dataclasses import dataclass, field
11-
from functools import partial, wraps
11+
from functools import partial
1212
from multiprocessing import cpu_count
1313
from queue import SimpleQueue
1414
from types import MappingProxyType
@@ -374,13 +374,15 @@ def __get__(self, instance: Any, owner: Optional[type] = None) -> Any:
374374

375375

376376
@overload
377-
def threaded(func: Callable[P, T]) -> Threaded[P, T]: ...
377+
def threaded(func: Callable[P, T]) -> Threaded[P, T]:
378+
...
378379

379380

380381
@overload
381382
def threaded(
382383
func: Callable[P, Generator[T, None, None]]
383-
) -> Callable[P, IteratorWrapper[P, T]]: ...
384+
) -> Callable[P, IteratorWrapper[P, T]]:
385+
...
384386

385387

386388
def threaded(
@@ -505,15 +507,18 @@ def threaded_iterable(
505507
func: Callable[P, Generator[T, None, None]],
506508
*,
507509
max_size: int = 0,
508-
) -> "ThreadedIterable[P, T]": ...
510+
) -> "ThreadedIterable[P, T]":
511+
...
509512

510513

511514
@overload
512515
def threaded_iterable(
513516
*,
514517
max_size: int = 0,
515518
) -> Callable[
516-
[Callable[P, Generator[T, None, None]]], ThreadedIterable[P, T]]: ...
519+
[Callable[P, Generator[T, None, None]]], ThreadedIterable[P, T]
520+
]:
521+
...
517522

518523

519524
def threaded_iterable(
@@ -522,14 +527,16 @@ def threaded_iterable(
522527
max_size: int = 0,
523528
) -> Union[
524529
ThreadedIterable[P, T],
525-
Callable[[Callable[P, Generator[T, None, None]]],
526-
ThreadedIterable[P, T]]
530+
Callable[
531+
[Callable[P, Generator[T, None, None]]], ThreadedIterable[P, T]
532+
]
527533
]:
528534
if func is None:
529535
return lambda f: ThreadedIterable(f, max_size=max_size)
530536

531537
return ThreadedIterable(func, max_size=max_size)
532538

539+
533540
class IteratorWrapperSeparate(IteratorWrapper):
534541
def _run(self) -> Any:
535542
return run_in_new_thread(self._in_thread)
@@ -550,7 +557,8 @@ def threaded_iterable_separate(
550557
func: Callable[P, Generator[T, None, None]],
551558
*,
552559
max_size: int = 0,
553-
) -> "ThreadedIterable[P, T]": ...
560+
) -> "ThreadedIterable[P, T]":
561+
...
554562

555563

556564
@overload
@@ -560,7 +568,8 @@ def threaded_iterable_separate(
560568
) -> Callable[
561569
[Callable[P, Generator[T, None, None]]],
562570
ThreadedIterableSeparate[P, T]
563-
]: ...
571+
]:
572+
...
564573

565574

566575
def threaded_iterable_separate(
@@ -569,16 +578,16 @@ def threaded_iterable_separate(
569578
max_size: int = 0,
570579
) -> Union[
571580
ThreadedIterable[P, T],
572-
Callable[[Callable[P, Generator[T, None, None]]],
573-
ThreadedIterableSeparate[P, T]]
581+
Callable[
582+
[Callable[P, Generator[T, None, None]]], ThreadedIterableSeparate[P, T]
583+
]
574584
]:
575585
if func is None:
576586
return lambda f: ThreadedIterableSeparate(f, max_size=max_size)
577587

578588
return ThreadedIterableSeparate(func, max_size=max_size)
579589

580590

581-
582591
class CoroutineWaiter:
583592
def __init__(
584593
self, coroutine: Coroutine[Any, Any, T],

aiomisc_worker/forking.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
def at_exit() -> None:
23-
global PROCESSES
23+
global PROCESSES # noqa
2424

2525
with EXIT_LOCK:
2626
pids = tuple(PROCESSES.keys())
@@ -61,7 +61,7 @@ def fork(worker_id: bytes, cookie: bytes, address: AddressType) -> None:
6161

6262

6363
def main() -> int:
64-
global STOPPING
64+
global STOPPING # noqa
6565

6666
proto_stdin = FileIOProtocol(sys.stdin.buffer)
6767

aiomisc_worker/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def main() -> int:
8686
env["AIOMISC_NO_PLUGINS"] = ""
8787

8888
def create_worker() -> Worker:
89-
nonlocal env
89+
nonlocal env # noqa
9090
return Worker(
9191
log_level, log_format, address, cookie, worker_id, env,
9292
initializer, initializer_args, initializer_kwargs,

tests/test_aggregate.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99

1010
import pytest
1111

12-
from aiomisc.aggregate import Arg, ResultNotSetError, aggregate, aggregate_async
13-
12+
from aiomisc.aggregate import Arg, ResultNotSetError, aggregate, \
13+
aggregate_async
1414

1515
log = logging.getLogger(__name__)
1616

17-
1817
pytestmark = pytest.mark.skipif(
1918
platform.system() == "Windows",
2019
reason="Skip flapping tests on windows because it "
@@ -104,7 +103,7 @@ async def test_leeway_ok(event_loop, leeway):
104103

105104
@aggregate(leeway * 1000)
106105
async def pow(*args: float, power: float = 2) -> List[float]:
107-
nonlocal t_exec
106+
nonlocal t_exec # noqa
108107
t_exec = time.time()
109108
event.set()
110109

@@ -210,7 +209,7 @@ async def test_leeway_cancel(event_loop, leeway):
210209

211210
@aggregate(leeway * 1000)
212211
async def pow(*args: float, power: float = 2) -> List[float]:
213-
nonlocal executions, executing_task, t_exec, delay_exec
212+
nonlocal executions, executing_task, t_exec, delay_exec # noqa
214213
t_exec = time.time()
215214
executions += 1
216215
executing_task = tasks[arg.get()]
@@ -269,7 +268,7 @@ async def test_max_count_cancel(event_loop):
269268

270269
@aggregate(leeway * 1000, max_count)
271270
async def pow(*args: float, power: float = 2) -> List[float]:
272-
nonlocal executions, executing_task, t_exec, delay_exec
271+
nonlocal executions, executing_task, t_exec, delay_exec # noqa
273272
t_exec = time.time()
274273
executions += 1
275274
executing_task = tasks[arg.get()]
@@ -328,7 +327,7 @@ async def test_max_count_multiple_batches_cancel(event_loop, leeway):
328327

329328
@aggregate(leeway * 1000, max_count)
330329
async def pow(*args: float, power: float = 2) -> List[float]:
331-
nonlocal executions, executing_task, delay_exec
330+
nonlocal executions, executing_task, delay_exec # noqa
332331
executions += 1
333332
executing_task = tasks[arg.get()]
334333
event.set()
@@ -404,7 +403,6 @@ async def pho(*args: Arg):
404403

405404

406405
async def test_low_level_ok(event_loop, leeway):
407-
408406
@aggregate_async(leeway * 1000)
409407
async def pow(*args: Arg, power: float = 2):
410408
for arg in args:
@@ -421,7 +419,6 @@ async def pow(*args: Arg, power: float = 2):
421419

422420

423421
async def test_low_level_error(event_loop, leeway):
424-
425422
@aggregate_async(leeway * 1000)
426423
async def pho(*args: Arg):
427424
for arg in args:

tests/test_cron.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def test_shield(event_loop):
5757
condition = asyncio.Condition()
5858

5959
async def task():
60-
nonlocal counter, condition
60+
nonlocal counter, condition # noqa
6161
counter += 1
6262
async with condition:
6363
condition.notify_all()
@@ -86,7 +86,7 @@ async def test_restart(event_loop):
8686
condition = asyncio.Condition()
8787

8888
async def task():
89-
nonlocal counter, condition
89+
nonlocal counter, condition # noqa
9090
counter += 1
9191
async with condition:
9292
condition.notify_all()

tests/test_cron_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_cron():
1515
condition: asyncio.Condition
1616

1717
async def callback():
18-
nonlocal counter
18+
nonlocal counter # noqa
1919
async with condition:
2020
counter += 1
2121
condition.notify_all()
@@ -25,7 +25,7 @@ async def callback():
2525
svc.register(callback, spec="* * * * * *")
2626

2727
async def assert_counter():
28-
nonlocal counter, svc
28+
nonlocal counter, svc # noqa
2929

3030
counter = 0
3131
async with condition:
@@ -74,7 +74,7 @@ async def callback():
7474
svc.register(callback, spec="* * * * * *")
7575

7676
async def assert_counter():
77-
nonlocal counter, svc
77+
nonlocal counter, svc # noqa
7878

7979
counter = 0
8080
async with condition:

tests/test_entrypoint.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ async def start(self):
149149

150150
with pytest.raises(TypeError):
151151
class NoAsyncStopServiceSubclass(MyService):
152-
def stop(self, *_) -> Any: # type: ignore
152+
def stop(self, *_) -> Any:
153153
return True
154154

155155
class AsyncStopServiceSubclass(MyService):
156-
async def stop(self, *_) -> Any: # type: ignore
156+
async def stop(self, *_) -> Any:
157157
return True
158158

159159

@@ -883,15 +883,15 @@ async def test_entrypoint_graceful_shutdown_loop_owner(event_loop):
883883
task: Task
884884

885885
async def func():
886-
nonlocal event
886+
nonlocal event # noqa
887887
await event.wait()
888888

889889
async def pre_start(**_):
890890
nonlocal task
891891
task = get_event_loop().create_task(func())
892892

893893
async def post_stop(**_):
894-
nonlocal event, task
894+
nonlocal event, task # noqa
895895
event.set()
896896
with suppress(asyncio.TimeoutError):
897897
await asyncio.wait_for(task, timeout=1.0)

tests/test_periodic_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def test_periodic(event_loop):
2525

2626
class CountPeriodicService(PeriodicService):
2727
async def callback(self):
28-
nonlocal counter
29-
nonlocal condition
28+
nonlocal counter # noqa
29+
nonlocal condition # noqa
3030

3131
async with condition:
3232
counter += 1
@@ -35,7 +35,7 @@ async def callback(self):
3535
svc = CountPeriodicService(interval=0.1)
3636

3737
async def assert_counter():
38-
nonlocal counter, svc
38+
nonlocal counter, svc # noqa
3939

4040
counter = 0
4141

@@ -71,7 +71,7 @@ async def callback(self):
7171
svc = CountPeriodicService(interval=0.1, delay=0.5)
7272

7373
async def assert_counter():
74-
nonlocal counter, svc
74+
nonlocal counter, svc # noqa
7575

7676
counter = 0
7777
await asyncio.sleep(0.25)

0 commit comments

Comments
 (0)