match..case type narrowing question #2050
Answered
by
yangdanny97
satya-waylit
asked this question in
Q&A
|
This is possibly not implemented yet or a bug. dict_or_none: dict[str, Any] | None = {"a": "b"}
match dict_or_none:
case None:
pass
case {"a": "b"}: # Object of class `NoneType` has no attribute `__getitem__`
pass
case _:
pass |
Answered by
yangdanny97
Jan 10, 2026
Replies: 1 comment
Answer selected by
satya-waylit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Likely a bug, filed #2058