Skip to content

@default decorator missing on KernelClient #1065

@krassowski

Description

@krassowski

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions