jspahrsummers / adt

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

add support for _ default key #35

Open ethanabrooks opened 4 years ago

ethanabrooks commented 4 years ago

In reference to https://github.com/jspahrsummers/adt/issues/34

ethanabrooks commented 4 years ago

done!

ethanabrooks commented 4 years ago

Hmmm I took a look at the typechecker, but it wasn't exactly clear how to add _ to the list of valid keyword arguments. Could you lend some guidance on that front?

jspahrsummers commented 4 years ago

Thanks for the test! It's been a while since I've hacked on the codebase myself, to be honest, but at a high level it would involve telling the typechecker about your new argument to match.

The tricky part that I foresee here is that the type of _ is quite open-ended (probably something like Callable[..., _MatchResult]). I'm not sure what mypy's API for that looks like, but it would look broadly similar to how we instantiate the other mypy.types.CallableTypes.

Hope that helps.