Repository navigation
Fix re.split(...) return type - #5269
Conversation
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
|
This change breaks a lot of code that assumes the list doesn't contain We have some options:
What do you think? |
|
This can also be implemented more precisely in a type checker plugin that could look at the regex to see if there are optional groups. |
|
I guess so. I was just startled when mypy assured me that split returns |
|
There's not a good way to express this in stubs. If you want, you can create a feature request to mypy. |
|
See #3902 for discussion about |
|
Another option is to use Type checkers can still optionally special case this based on the regular expression string and provide more precise types when possible. |
|
Yeah that sounds nice. |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
re.split(...) return type
Example: