Skip to content

Commit

Permalink
traitlets typing doesn't handle abcs unless they are strings
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Oct 25, 2024
1 parent 947894b commit e9555d4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import sys
import threading
import typing as t
from collections.abc import Mapping
from dataclasses import dataclass

import comm
Expand All @@ -19,7 +18,7 @@
from IPython.core import release
from IPython.utils.tokenutil import line_at_cursor, token_at_cursor
from jupyter_client.session import extract_header
from traitlets import Any, Bool, HasTraits, Instance, List, Type, observe, observe_compat
from traitlets import Any, Bool, HasTraits, Instance, List, Type, default, observe, observe_compat

from .comm.comm import BaseComm
from .comm.manager import CommManager
Expand Down Expand Up @@ -87,7 +86,11 @@ def _user_module_changed(self, change):
if self.shell is not None:
self.shell.user_module = change["new"]

user_ns = Instance(Mapping, args=None, allow_none=True)
user_ns = Instance("collections.abc.Mapping", allow_none=True)

@default("user_ns")
def _default_user_ns(self):
return dict()

@observe("user_ns")
@observe_compat
Expand Down

0 comments on commit e9555d4

Please sign in to comment.