Conversation
|
Hum, looks like mypy==1.6.0 is crashing on our Flask-SocketIO stubs without printing any traceback to the terminal. You can see that in our CI; I can also reproduce by creating a new virtual environment, then running these steps: $ pip install "mypy==1.6.0" "Flask>=0.9" --no-cache-dir
$ python -m mypy --python-version 3.12 --show-traceback --warn-incomplete-stub --no-error-summary --platform win32 --custom-typeshed-dir . --strict --allow-untyped-defs --allow-incomplete-defs --allow-subclassing-any --enable-error-code ignore-without-code --explicit-package-bases stubs\Flask-SocketIO\flask_socketio\__init__.pyi stubs\Flask-SocketIO\flask_socketio\namespace.pyi stubs\Flask-SocketIO\flask_socketio\test_client.pyi |
Hmmmmm, well, Third-party stubtest is still giving exit code 1 due to the crash, though: https://github.com/python/typeshed/actions/runs/6475810434/job/17583487385?pr=10862 |
This comment has been minimized.
This comment has been minimized.
|
I'll investigate more in the morning; it's late here now. Seems like both mypy and mypy_test.py are buggy here. |
I can't reproduce this behaviour locally. If I run Script output: |
|
It also fails for me locally (Python 3.11.4, Ubuntu): I'll see if I can find anything. |
|
I minimised the mypy crash: But don't know what's going on with mypy_test.py. |
|
The problem with mypy_test was that mypy returned exit code -11, but mypy_test was combining exit codes using |
Great find. And, interesting! Locally, I was getting exit code 3221225725. |
|
Nice(?!), it fails now. |
Yes -- hooray(??) -- we now correctly get 15 more CI errors |
This comment has been minimized.
This comment has been minimized.
|
This diff works around the mypy crash, with only a very minor readability cost: --- a/stubs/Flask-SocketIO/flask_socketio/__init__.pyi
+++ b/stubs/Flask-SocketIO/flask_socketio/__init__.pyi
@@ -13,10 +13,9 @@ from .test_client import SocketIOTestClient
_P = ParamSpec("_P")
_R_co = TypeVar("_R_co", covariant=True)
_ExceptionHandler: TypeAlias = Callable[[BaseException], _R_co]
-_Handler: TypeAlias = Callable[_P, _R_co]
class _HandlerDecorator(Protocol):
- def __call__(self, handler: _Handler[_P, _R_co]) -> _Handler[_P, _R_co]: ...
+ def __call__(self, handler: Callable[_P, _R_co]) -> Callable[_P, _R_co]: ...
class _ExceptionHandlerDecorator(Protocol):
def __call__(self, exception_handler: _ExceptionHandler[_R_co]) -> _ExceptionHandler[_R_co]: ...
@@ -52,9 +51,9 @@ class SocketIO:
def on(self, message: str, namespace: str | None = None) -> _HandlerDecorator: ...
def on_error(self, namespace: str | None = None) -> _ExceptionHandlerDecorator: ...
def on_error_default(self, exception_handler: _ExceptionHandler[_R_co]) -> _ExceptionHandler[_R_co]: ...
- def on_event(self, message: str, handler: _Handler[[Incomplete], object], namespace: str | None = None) -> None: ...
+ def on_event(self, message: str, handler: Callable[[Incomplete], object], namespace: str | None = None) -> None: ...
@overload
- def event(self, __event_handler: _Handler[_P, _R_co]) -> _Handler[_P, _R_co]: ...
+ def event(self, __event_handler: Callable[_P, _R_co]) -> Callable[_P, _R_co]: ...
@overload
def event(self, namespace: str | None = None, *args, **kwargs) -> _HandlerDecorator: ...
def on_namespace(self, namespace_handler: Namespace) -> None: ...Two other options are: What do we like the sound of best? |
|
Since it's quite likely that we'll get a mypy 1.6.1 in a few days fixing the crash, I think we should wait at least a little. |
Note that -11 is a segfault (on Unix). That explains why Alex saw something different on Windows. I would expect something like python/mypy#16245 to result in a segfault when mypy is compiled with mypyc; @AlexWaygood presumably got the repro case there by using uncompiled mypy. |
Yes, I only got the stack trace using uncompiled mypy (using the |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
There's a few more stubtest allowlist entries now, due to a new check where stubtest emits an error if a stdlib module exists at runtime, but isn't present in the stubs.
I'm not sure what's going on with all the new stubtest errors on
_dummy_threadingon py38. But it's an internal module that was removed in py39, so I don't think it matters too much.