diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3018c2e..ec0bc40 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,12 +41,23 @@ 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: install coverage + run: pip install coverage - name: upload coverage - run: pip install coveralls && coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} - - name: print coverage - run: pip install coverage && coverage report + uses: coverallsapp/github-action@v2 + with: + 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 diff --git a/asyncio_connection_pool/__init__.py b/asyncio_connection_pool/__init__.py index 62fcb98..025f41c 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 @@ -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 @@ -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: diff --git a/riotfile.py b/riotfile.py index 0a0c4d5..215be63 100644 --- a/riotfile.py +++ b/riotfile.py @@ -4,12 +4,12 @@ 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={ - "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", ), ],