by throwaway343244 · 4y ago · 0 comments
This would be flagged as unreachable I believe.
mypy/pyright also supports exhaustive checking with unions
def get_activation(key: Literal['sigmoid', 'tanh']) -> nn.Module:
match key:
case 'sigmoid': return nn.Sigmoid()
case 'tanh': return nn.tanh()
There are limits to mypy/pyright's exhaustive checker.. it will fail if the union is in CNF, you will need to convert it to DNF.No comments yet.