beartype / plum

Multiple dispatch in Python

Home Page:https://beartype.github.io/plum

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configure mypy for CI

nstarman opened this issue · comments

It would be great to add type annotations to plum! They should be tested, e.g. by pre-commit, with a configuration in pyproject.toml.

Hey @nstarman! I fully agree that adding type annotations and eanbling mypy would be helpful.

One problem is that multiple dispatch really doesn't play nicely with type checkers like mypy. There are some patterns where you can get things to work together, but getting mypy to be happy with code that uses the full feature set of Plum is really challenging. This is the main reason I haven't enabled mypy yet.

Agreed! It often doesn't work with mypy. Where it does work, having static checks are the gold standard. Where it doesn't, maybe using beartype itself would be sufficient? mypy in pre-commit can be configured to only run on select files. My suggestion is to configure mypy nicely and filter out all files. Then select files can be added as they are typed and if they will support static checks.

@nstarman That sounds very reasonable. I'd be very happy to only enable mypy for the files, or parts thereof where it would work. That would be a nice addition! :)

I'm going to be busy for about as week, but should have some capacity after that.