Skip to content

Commit

Permalink
Fix some complains from mypy --strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Dec 10, 2024
1 parent 9295c35 commit 70159fb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
48 changes: 27 additions & 21 deletions picows/picows.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class WSFrame:
def get_payload_as_memoryview(self) -> memoryview: ...
def get_close_code(self) -> WSCloseCode: ...
def get_close_message(self) -> bytes: ...
def __str__(self): ...
def __str__(self) -> str: ...


class WSTransport:
Expand All @@ -97,24 +97,24 @@ class WSTransport:
message: Optional[WSBuffer],
fin: bool = True,
rsv1: bool = False,
): ...
def send_ping(self, message: Optional[WSBuffer]=None): ...
def send_pong(self, message: Optional[WSBuffer]=None): ...
def send_close(self, close_code: WSCloseCode = ..., close_message: Optional[WSBuffer]=None): ...
def disconnect(self, graceful: bool = True): ...
async def wait_disconnected(self): ...
) -> None: ...
def send_ping(self, message: Optional[WSBuffer]=None) -> None: ...
def send_pong(self, message: Optional[WSBuffer]=None) -> None: ...
def send_close(self, close_code: WSCloseCode = ..., close_message: Optional[WSBuffer]=None) -> None: ...
def disconnect(self, graceful: bool = True) -> None: ...
async def wait_disconnected(self) -> None: ...
async def measure_roundtrip_time(self, rounds: int) -> list[float]: ...
def notify_user_specific_pong_received(self): ...
def notify_user_specific_pong_received(self) -> None: ...


class WSListener:
def on_ws_connected(self, transport: WSTransport): ...
def on_ws_frame(self, transport: WSTransport, frame: WSFrame): ...
def on_ws_disconnected(self, transport: WSTransport): ...
def send_user_specific_ping(self, transport: WSTransport): ...
def is_user_specific_pong(self, frame: WSFrame): ...
def pause_writing(self): ...
def resume_writing(self): ...
def on_ws_connected(self, transport: WSTransport) -> None: ...
def on_ws_frame(self, transport: WSTransport, frame: WSFrame) -> None: ...
def on_ws_disconnected(self, transport: WSTransport) -> None: ...
def send_user_specific_ping(self, transport: WSTransport) -> None: ...
def is_user_specific_pong(self, frame: WSFrame) -> bool: ...
def pause_writing(self) -> None: ...
def resume_writing(self) -> None: ...


class WSUpgradeRequest:
Expand All @@ -128,15 +128,21 @@ class WSUpgradeRequest:
def version(self) -> bytes: ...

@property
def headers(self) -> CIMultiDict: ...
def headers(self) -> CIMultiDict[str]: ...


class WSUpgradeResponse:
@staticmethod
def create_error_response(status: Union[int, HTTPStatus], body=None, extra_headers: Optional[WSHeadersLike]=None): ...
def create_error_response(
status: Union[int, HTTPStatus],
body: Optional[bytes]=None,
extra_headers: Optional[WSHeadersLike]=None
) -> WSUpgradeResponse: ...

@staticmethod
def create_101_response(extra_headers: Optional[WSHeadersLike]=None): ...
def create_101_response(
extra_headers: Optional[WSHeadersLike]=None
) -> WSUpgradeResponse: ...

@property
def version(self) -> bytes: ...
Expand All @@ -145,7 +151,7 @@ class WSUpgradeResponse:
def status(self) -> HTTPStatus: ...

@property
def headers(self) -> CIMultiDict: ...
def headers(self) -> CIMultiDict[str]: ...


class WSUpgradeResponseWithListener:
Expand All @@ -158,7 +164,7 @@ async def ws_connect(
*,
ssl_context: Union[SSLContext, None] = None,
disconnect_on_exception: bool = True,
websocket_handshake_timeout=5,
websocket_handshake_timeout: float = 5,
logger_name: str = "client",
enable_auto_ping: bool = False,
auto_ping_idle_timeout: float = 10,
Expand All @@ -176,7 +182,7 @@ async def ws_create_server(
port: Union[int, None] = None,
*,
disconnect_on_exception: bool = True,
websocket_handshake_timeout: int = 5,
websocket_handshake_timeout: float = 5,
logger_name: str = "server",
enable_auto_ping: bool = False,
auto_ping_idle_timeout: float = 20,
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ version = {attr = "picows.__version__"}
[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"

[tool.mypy]
files = "picows"
ignore_missing_imports = true
strict = true

0 comments on commit 70159fb

Please sign in to comment.