beartype / plum

Multiple dispatch in Python
https://beartype.github.io/plum
MIT License
508 stars 24 forks source link

Configure mypy for CI #147

Open nstarman opened 2 months ago

nstarman commented 2 months ago

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.

wesselb commented 1 month ago

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.

nstarman commented 1 month ago

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.

wesselb commented 1 month ago

@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.