"Structural pattern matching" for Python, part 1
"Structural pattern matching" for Python, part 1
Posted Aug 5, 2020 21:33 UTC (Wed) by NYKevin (subscriber, #129325)In reply to: "Structural pattern matching" for Python, part 1 by re:fi.64
Parent article: "Structural pattern matching" for Python, part 1
I think that will depend to some extent on the ability of the type linter to produce refutations. If the type linter cannot prove that a pattern (or series of patterns) is irrefutable, but it also cannot provide a sample refutation to those patterns, then the developer will be tempted to shove in a case _: pass clause "to make the type linter shut up." Depending on the circumstances, this may or may not be safe, and it certainly won't be future proof (if the patterns are later changed in such a way that they really do become refutable, then the type linter won't see anything wrong with the match).
On the other hand, if the type linter can guarantee that it will always be able to come up with a specific refutation, then it may actually help catch bugs much earlier in development. Given the complexity of Python's dynamic typing system, I think this is still a bit of an open problem, although I welcome corrections on this point.
