Support narrowing using in
keyword
#2596
kumaraditya303
started this conversation in
Ideas
Replies: 1 comment
-
FWIW, mypy doesn't currently provide narrowing support for this pattern. There is an open issue, but it hasn't received many upvotes yet. Here is another related feature request. We'll wait to see if others upvote this request. In the meantime, you can implement your own user-defined type guard function using the PEP 647 functionality. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
See this code:
Pyright is able to narrow in first case of
isinstance
but not in second case. This is very popular pattern in python so worth to be considered.Objects which should be supported in initial implementation:
set
tuple
list
deque
Beta Was this translation helpful? Give feedback.
All reactions