Skip to content

Commit db50ecc

Browse files
committed
Linter + CI rules for testing
1 parent b2abd77 commit db50ecc

4 files changed

Lines changed: 53 additions & 8 deletions

File tree

.github/workflows/python-app.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
python-version: ["3.12", "3.13", "3.14"]
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
allow-prereleases: true
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install flake8
35+
pip install .[dev]
36+
- name: Lint with flake8
37+
run: |
38+
# stop the build if there are Python syntax errors or undefined names
39+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
40+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
41+
# flake8 extraasync --count --exit-zero --max-complexity=15 --max-line-length=200 --statistics
42+
- name: Test with pytest
43+
run: |
44+
pytest -v

extraasync/async_hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def run_forever(self):
9999
if not hasattr(asyncio.BaseEventLoop, "_run_forever_cleanup"):
100100

101101
warnings.warn(
102-
f"asyncio.BaseEventLoop no longer implements '_run_forever_cleanup', This means the "
102+
"asyncio.BaseEventLoop no longer implements '_run_forever_cleanup', This means the "
103103
"'at_loop_stop_callback' function will fail! Please, add an issue to the project reporting this at "
104104
"https://github.com/jsbueno/extraasync"
105105
)

extraasync/sync_async_bridge.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
logger = logging.getLogger(__name__)
2020
#############################
21-
### debugging logger boilerplate
21+
# debugging logger boilerplate
2222

2323
if os.environ.get("EXTRAASYNC_DEBUG"):
2424

@@ -85,7 +85,8 @@ def sync_to_async(
8585
this will allow the nested call to
8686
happen in the context of that original loop. This enables the creation of
8787
a single code path to both async and asynchronous contexts. In other words,
88-
and async function which calls a synchronous function by awaiting the "async_to_sync" counterpart to this function can have the synchronous function call back
88+
and async function which calls a synchronous function by awaiting the
89+
"async_to_sync" counterpart to this function can have the synchronous function call back
8990
asynchronous contexts using this call. This is the so called "bridge mode" [WIP]
9091
"""
9192

@@ -117,7 +118,7 @@ def do_it():
117118
logger.debug(
118119
"Creating task in %s from %s",
119120
loop,
120-
thread_name := threading.current_thread().name,
121+
threading.current_thread().name,
121122
)
122123
try:
123124
task = loop.create_task(coro, context=sync_thread_context_copy)
@@ -214,7 +215,7 @@ def close_threads(self):
214215

215216
def __repr__(self):
216217
running = bool(self.running.get())
217-
return f"<_ThreadPool with {len(self.all)} threads - with {len(self.all) - len(self.idle)} threads in use>"
218+
return f"<_ThreadPool with {len(self.all)} threads - with {len(self.all) - len(self.idle)} threads in use {running =}>"
218219

219220

220221
def _in_context_sync_worker(sync_task: _SyncTask):

extraasync/taskgroup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from asyncio import TaskGroup
22

33
# Idea originally developed for an answer on StackOverflow
4-
# at: https://stackoverflow.com/questions/75250788/how-to-prevent-python3-11-taskgroup-from-canceling-all-the-tasks/75261668#75261668
4+
# at: https://stackoverflow.com/questions/75250788/how-to-prevent-python3-11-taskgroup-from-canceling-all-the-tasks/75261668#75261668 #noQA
55

66
# The class in this project provided under LGPL-V3
77

@@ -10,11 +10,11 @@
1010
import warnings
1111

1212
warnings.warn(
13-
f"asyncio.TaskGroup no longer implements '_abort', This means the ExtraTaskGroup "
13+
"asyncio.TaskGroup no longer implements '_abort', This means the ExtraTaskGroup "
1414
"class will fail! Please, add an issue to the project reporting this at "
1515
"https://github.com/jsbueno/extraasync"
1616
)
1717

1818

1919
class ExtraTaskGroup(TaskGroup):
20-
_abort = lambda self: None
20+
_abort = lambda self: None # noQA

0 commit comments

Comments
 (0)