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

Function mypy_enum_typing

tests/test_typing.py:214–246  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

212
213@pytest.mark.mypy_testing
214def mypy_enum_typing() -> None:
215 class T(HasTraits):
216 log_level = Enum(
217 (0, 10, 20, 30, 40, 50),
218 default_value=logging.WARN,
219 help="Set the log level by value or name.",
220 ).tag(config=True)
221
222 t = T()
223 reveal_type(
224 Enum( # R: traitlets.traitlets.Enum[builtins.str]
225 ("foo",)
226 )
227 )
228 reveal_type(
229 Enum( # R: traitlets.traitlets.Enum[builtins.str]
230 [""]
231 ).tag(sync=True)
232 )
233 reveal_type(
234 Enum( # R: traitlets.traitlets.Enum[None]
235 None, allow_none=True
236 )
237 )
238 reveal_type(
239 Enum( # R: traitlets.traitlets.Enum[None]
240 None, allow_none=True
241 ).tag(sync=True)
242 )
243 reveal_type(
244 T.log_level # R: traitlets.traitlets.Enum[builtins.int]
245 )
246 reveal_type(t.log_level) # R: builtins.int
247
248
249@pytest.mark.mypy_testing

Callers

nothing calls this directly

Calls 4

EnumClass · 0.90
TClass · 0.85
reveal_typeFunction · 0.85
tagMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…