From 90f24ae427824e68fb6d1db6f107dc6f85f555d6 Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Mon, 27 Mar 2023 14:53:14 -0400 Subject: [PATCH 1/9] fix type annotation on ConnectionStrategy.make_connection --- asyncio_connection_pool/__init__.py | 4 ++-- asyncio_connection_pool/contrib/datadog.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/asyncio_connection_pool/__init__.py b/asyncio_connection_pool/__init__.py index 62fcb98..ef39e27 100644 --- a/asyncio_connection_pool/__init__.py +++ b/asyncio_connection_pool/__init__.py @@ -10,7 +10,7 @@ class ConnectionStrategy(ABC, Generic[Conn]): @abstractmethod - async def make_connection(self) -> Awaitable[Conn]: + async def make_connection(self) -> Conn: ... @abstractmethod @@ -132,7 +132,7 @@ def _get_conn(self) -> "Awaitable[Conn]": return self._loop.create_task(self._connection_waiter()) @asynccontextmanager - async def get_connection(self) -> AsyncIterator[Conn]: # type: ignore + async def get_connection(self) -> AsyncIterator[Conn]: # _get_conn atomically does any book-keeping and returns an awaitable # that resolves to a connection. conn = await self._get_conn() diff --git a/asyncio_connection_pool/contrib/datadog.py b/asyncio_connection_pool/contrib/datadog.py index 2b96843..e8438fe 100644 --- a/asyncio_connection_pool/contrib/datadog.py +++ b/asyncio_connection_pool/contrib/datadog.py @@ -122,7 +122,7 @@ def _get_conn(self): return super()._get_conn() @asynccontextmanager - async def get_connection(self) -> AsyncIterator[Conn]: # type: ignore + async def get_connection(self) -> AsyncIterator[Conn]: async with AsyncExitStack() as stack: self._record_connection_acquiring(1) try: From 11ead32ce9819f876268589ad8794c89fc5215ce Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Mon, 27 Mar 2023 15:00:09 -0400 Subject: [PATCH 2/9] update lint deps --- riotfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/riotfile.py b/riotfile.py index 0a0c4d5..d5b6bc5 100644 --- a/riotfile.py +++ b/riotfile.py @@ -8,8 +8,8 @@ name="test", command="pytest {cmdargs}", pkgs={ - "pytest": "==6.2.5", - "pytest-asyncio": "==0.16.0", + "pytest": latest, + "pytest-asyncio": latest, "pytest-cov": latest, # extras_require "ddtrace": latest, @@ -21,11 +21,11 @@ name="mypy", command="mypy asyncio_connection_pool", pkgs={ - "mypy": "==0.790", + "mypy": "==1.1.1", }, ), Venv( - pkgs={"black": "==22.3.0"}, + pkgs={"black": "==23.1.0"}, venvs=[ Venv( name="fmt", @@ -39,7 +39,7 @@ ), Venv( name="flake8", - pkgs={"flake8": "==3.8.4"}, + pkgs={"flake8": "==6.0.0"}, command="flake8 test asyncio_connection_pool", ), ], From fb76d0053889d94ae72aaaae9e85fbe0db273701 Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Wed, 29 May 2024 13:30:37 -0400 Subject: [PATCH 3/9] add more type annotations --- asyncio_connection_pool/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/asyncio_connection_pool/__init__.py b/asyncio_connection_pool/__init__.py index ef39e27..025f41c 100644 --- a/asyncio_connection_pool/__init__.py +++ b/asyncio_connection_pool/__init__.py @@ -61,7 +61,7 @@ def __init__( strategy: ConnectionStrategy[Conn], max_size: int, burst_limit: Optional[int] = None - ): + ) -> None: self._loop = asyncio.get_event_loop() self.strategy = strategy self.max_size = max_size @@ -82,7 +82,7 @@ def _waiters(self) -> int: waiters = self.available._getters # type: ignore return sum(not (w.done() or w.cancelled()) for w in waiters) - async def _connection_maker(self): + async def _connection_maker(self) -> Conn: try: conn = await self.strategy.make_connection() finally: @@ -90,12 +90,12 @@ async def _connection_maker(self): self.in_use += 1 return conn - async def _connection_waiter(self): + async def _connection_waiter(self) -> Conn: conn = await self.available.get() self.in_use += 1 return conn - def _get_conn(self) -> "Awaitable[Conn]": + def _get_conn(self) -> Awaitable[Conn]: # This function is how we avoid explicitly locking. Since it is # synchronous, we do all the "book-keeping" required to get a # connection synchronously, and return a Future or Task which can be From 8bae5c4d9897e47cba94c286978b34a71d255b66 Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Wed, 29 May 2024 13:42:40 -0400 Subject: [PATCH 4/9] update riot in CI --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3018c2e..e8611da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.9" - - run: pip install riot==0.4.0 + - run: pip install riot==0.19.0 - run: riot -v run -s black -- --check . mypy: runs-on: ubuntu-latest @@ -17,7 +17,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.9" - - run: pip install riot==0.4.0 + - run: pip install riot==0.19.0 - run: riot -v run mypy flake8: runs-on: ubuntu-latest @@ -26,7 +26,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.9" - - run: pip install riot==0.4.0 + - run: pip install riot==0.19.0 - run: riot -v run flake8 test: strategy: @@ -41,7 +41,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: install riot - run: pip install riot==0.4.0 + run: pip install riot==0.19.0 - name: run tests run: riot -v run --python=${{ matrix.python-version }} test -- --cov=asyncio_connection_pool --cov-branch --cov-config=.coveragerc - name: upload coverage From 32b515c0d38d83790bb92dcd113c6425b82ff386 Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Wed, 29 May 2024 13:46:40 -0400 Subject: [PATCH 5/9] add 3.11 and 3.12 to test venv in riotfile --- riotfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riotfile.py b/riotfile.py index d5b6bc5..215be63 100644 --- a/riotfile.py +++ b/riotfile.py @@ -4,7 +4,7 @@ pys=3, venvs=[ Venv( - pys=["3.8", "3.9", "3.10"], + pys=["3.8", "3.9", "3.10", "3.11", "3.12"], name="test", command="pytest {cmdargs}", pkgs={ From 3a8fde71d033f60c9d5e3676a95cd8152ddb7bd4 Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Wed, 29 May 2024 13:51:13 -0400 Subject: [PATCH 6/9] fix uploading code coverage --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8611da..0969488 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,8 +45,6 @@ jobs: - name: run tests run: riot -v run --python=${{ matrix.python-version }} test -- --cov=asyncio_connection_pool --cov-branch --cov-config=.coveragerc - name: upload coverage - run: pip install coveralls && coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + uses: coverallsapp/github-action@v2 - name: print coverage run: pip install coverage && coverage report From d60e6a6574520d37a21f3825505863bb9ff05147 Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Wed, 29 May 2024 14:11:50 -0400 Subject: [PATCH 7/9] debug coveralls --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0969488..57ce1dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,5 +46,7 @@ jobs: run: riot -v run --python=${{ matrix.python-version }} test -- --cov=asyncio_connection_pool --cov-branch --cov-config=.coveragerc - name: upload coverage uses: coverallsapp/github-action@v2 + with: + debug: true - name: print coverage run: pip install coverage && coverage report From de8630eb80a96478fdf166a51c19148449c5025b Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Wed, 29 May 2024 14:19:06 -0400 Subject: [PATCH 8/9] install coverage before coveralls action --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57ce1dc..85543e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,9 +44,9 @@ jobs: run: pip install riot==0.19.0 - name: run tests run: riot -v run --python=${{ matrix.python-version }} test -- --cov=asyncio_connection_pool --cov-branch --cov-config=.coveragerc + - name: install coverage + run: pip install coverage - name: upload coverage uses: coverallsapp/github-action@v2 with: debug: true - - name: print coverage - run: pip install coverage && coverage report From 6e49f6edc45dd178a33c28f8e66bc9fd475ef2c2 Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Wed, 29 May 2024 14:33:03 -0400 Subject: [PATCH 9/9] use coveralls action parallel mode --- .github/workflows/ci.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85543e6..ec0bc40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,4 +49,15 @@ jobs: - name: upload coverage uses: coverallsapp/github-action@v2 with: - debug: true + parallel: true + flag-name: run ${{ join(matrix.*, ' - ') }} + finish-coveralls: + needs: test + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true + allow-empty: true