Compare:
MultiKernelManager (ok):
|
@default("context") |
|
def _context_default(self) -> zmq.Context: |
|
self._created_context = True |
|
return zmq.Context() |
KernelManager (ok):
|
_created_context: Bool = Bool(False) |
|
|
|
# The PyZMQ Context to use for communication with the kernel. |
|
context: Instance = Instance(zmq.Context) |
|
|
|
@default("context") |
|
def _context_default(self) -> zmq.Context: |
|
self._created_context = True |
|
return zmq.Context() |
KernelClient and AsyncKernelClient (wrong?):
|
context = Instance(zmq.Context) |
|
|
|
_created_context = Bool(False) |
|
|
|
def _context_default(self) -> zmq.Context: |
|
self._created_context = True |
|
return zmq.Context() |
|
context = Instance(zmq.asyncio.Context) # type:ignore[arg-type] |
|
|
|
def _context_default(self) -> zmq.asyncio.Context: |
|
self._created_context = True |
|
return zmq.asyncio.Context() |
Technically I think this is not wrong, just old way of doing things as per:
https://traitlets.readthedocs.io/en/stable/migration.html#dynamic-defaults-generation-with-decorators
The use of the magic methods _{trait}_default for dynamic default generation is not deprecated, but a new @default method decorator is added
Compare:
MultiKernelManager(ok):jupyter_client/jupyter_client/multikernelmanager.py
Lines 107 to 110 in 1f36fbf
KernelManager(ok):jupyter_client/jupyter_client/manager.py
Lines 126 to 134 in 1f36fbf
KernelClientandAsyncKernelClient(wrong?):jupyter_client/jupyter_client/client.py
Lines 91 to 97 in 1f36fbf
jupyter_client/jupyter_client/asynchronous/client.py
Lines 36 to 40 in 1f36fbf
Technically I think this is not wrong, just old way of doing things as per:
https://traitlets.readthedocs.io/en/stable/migration.html#dynamic-defaults-generation-with-decorators