Skip to content

Commit

Permalink
Merge pull request #29 from tarasko/feature/mypy_ci
Browse files Browse the repository at this point in the history
Add mypy-checks to CI pipeline
  • Loading branch information
tarasko authored Dec 10, 2024
2 parents 70159fb + 1623c80 commit f1a6d38
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,33 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
mypy-checks:
strategy:
matrix:
pyver: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
fail-fast: false

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.pyver }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy
pip install -r requirements-test.txt
- name: Run mypy
run: |
mypy picows # Replace with your library directory
build:
strategy:
matrix:
Expand Down
18 changes: 11 additions & 7 deletions picows/picows.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ from enum import Enum
from ssl import SSLContext
from http import HTTPStatus

# Some of the imports are deprecated in the newer python versions
# TODO: Some of the imports are deprecated in the newer python versions
# But we still have support for 3.8 where collection.abc didn't have
# proper types yet.
from typing import Final, Optional, Mapping, Iterable, Tuple, Callable, Union
# Change this to collection.abc when 3.8 support is over.
from typing import Final, Optional, Mapping, Iterable, Tuple, Callable, Union, Any
from multidict import CIMultiDict


Expand Down Expand Up @@ -161,7 +162,7 @@ class WSUpgradeResponseWithListener:
async def ws_connect(
ws_listener_factory: Callable[[], WSListener],
url: str,
*,
*args: Any,
ssl_context: Union[SSLContext, None] = None,
disconnect_on_exception: bool = True,
websocket_handshake_timeout: float = 5,
Expand All @@ -172,15 +173,18 @@ async def ws_connect(
auto_ping_strategy: WSAutoPingStrategy = ...,
enable_auto_pong: bool = True,
extra_headers: Optional[WSHeadersLike] = None,
**kwargs,
**kwargs: Any
) -> Tuple[WSTransport, WSListener]: ...

# TODO: In python 3.8 asyncio has a bug that it doesn't export Server,
# so reference it directly from asyncio.base_events.
# Soon python 3.8 support will be gone and we can annotate asyncio.Server

async def ws_create_server(
ws_listener_factory: WSServerListenerFactory,
host: Union[str, Iterable[str], None] = None,
port: Union[int, None] = None,
*,
*args: Any,
disconnect_on_exception: bool = True,
websocket_handshake_timeout: float = 5,
logger_name: str = "server",
Expand All @@ -189,5 +193,5 @@ async def ws_create_server(
auto_ping_reply_timeout: float = 20,
auto_ping_strategy: WSAutoPingStrategy = ...,
enable_auto_pong: bool = True,
**kwargs,
) -> asyncio.Server: ...
**kwargs: Any
) -> asyncio.base_events.Server: ...

0 comments on commit f1a6d38

Please sign in to comment.