MCPcopy Create free account
hub / github.com/ipython/traitlets / parse_notifier_name

Function parse_notifier_name

traitlets/traitlets.py:200–224  ·  view source on GitHub ↗

Convert the name argument to a list of names. Examples -------- >>> parse_notifier_name([]) [traitlets.All] >>> parse_notifier_name("a") ['a'] >>> parse_notifier_name(["a", "b"]) ['a', 'b'] >>> parse_notifier_name(All) [traitlets.All]

(names: Sentinel | str | t.Iterable[Sentinel | str])

Source from the content-addressed store, hash-verified

198
199
200def parse_notifier_name(names: Sentinel | str | t.Iterable[Sentinel | str]) -> t.Iterable[t.Any]:
201 """Convert the name argument to a list of names.
202
203 Examples
204 --------
205 >>> parse_notifier_name([])
206 [traitlets.All]
207 >>> parse_notifier_name("a")
208 ['a']
209 >>> parse_notifier_name(["a", "b"])
210 ['a', 'b']
211 >>> parse_notifier_name(All)
212 [traitlets.All]
213 """
214 if names is All or isinstance(names, str):
215 return [names]
216 elif isinstance(names, Sentinel):
217 raise TypeError("`names` must be either `All`, a str, or a list of strs.")
218 else:
219 if not names or All in names:
220 return [All]
221 for n in names:
222 if not isinstance(n, str):
223 raise TypeError(f"names must be strings, not {type(n).__name__}({n!r})")
224 return names
225
226
227class _SimpleTest:

Callers 2

observeMethod · 0.85
unobserveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…