jupyter / jupyter_client

Jupyter protocol client APIs
https://jupyter-client.readthedocs.io
BSD 3-Clause "New" or "Revised" License
383 stars 283 forks source link

Correct `Any` type annotations. #791

Closed joouha closed 2 years ago

joouha commented 2 years ago

In some places it appears that traitlets.Any is used in place of typing.Any for type annotations.

This causes mypy errors in projects which depend on jupyter_client, e.g.:

euporie/kernel.py: note: In member "start_" of class "NotebookKernel":
euporie/kernel.py:233: error: Argument "stdout" has incompatible type "int"; expected "traitlets.traitlets.Any"  [arg-type]
                await self.km.start_kernel(stdout=DEVNULL, stderr=STDOUT)
                                                  ^
euporie/kernel.py:233: error: Argument "stderr" has incompatible type "int"; expected "traitlets.traitlets.Any"  [arg-type]
                await self.km.start_kernel(stdout=DEVNULL, stderr=STDOUT)
                                                                  ^
euporie/kernel.py: note: In member "history_" of class "NotebookKernel":
euporie/kernel.py:670: error: Argument "pattern" to "history" of "KernelClient" has incompatible type "str"; expected "traitlets.traitlets.Any"  [arg-type]
            msg_id = self.kc.history(pattern=pattern, n=n, hist_access_type="search")
                                             ^
euporie/kernel.py:670: error: Argument "n" to "history" of "KernelClient" has incompatible type "int"; expected "traitlets.traitlets.Any"  [arg-type]
            msg_id = self.kc.history(pattern=pattern, n=n, hist_access_type="search")
                                                        ^

This PR fixes all the instances of this I could find.

davidbrochart commented 2 years ago

Thanks a lot @joouha, I pushed more fixes and updated pyzmq >=23.0. It looks like the callback passed to ZMQStream.on_recv accepts an argument that doesn't need to be awaited anymore with pyzmq v23.0. Could you confirm @minrk ?