jspahrsummers / adt

Algebraic data types for Python (experimental, not actively maintained)
MIT License
172 stars 14 forks source link

mypy plugin: match-function returning None does not type-check #25

Closed wchresta closed 3 years ago

wchresta commented 4 years ago

Running the plugin with mypy==0.711 on the following code leads to an error:

from adt import adt, Case

@adt
class Expression:
    LITERAL: Case[float]

result: None = Expression.LITERAL(0.1).match(literal=lambda n: None)
error: Cannot infer type argument 1 of "match" of "Expression"

This does not happen when using something other than None as return values:

result: int = Expression.LITERAL(0.1).match(literal=lambda n: 1)