pymitter icon indicating copy to clipboard operation
pymitter copied to clipboard

Make pymitter type-safe

Open Klavionik opened this issue 5 months ago • 0 comments

Hey! I'm using pymitter in a couple of projects and I'm really missing the type hints. So this is my attempt to fix this problem.

What I did:

  1. I tried to make pymitter as type-safe as I could, except for Tree.add_listener method, where I had to leave some type: ignore directives. I believe it is fixable, but requires some refactoring.
  2. I made mypy checks compatible with Python 3.7, so I've extended the test matrix.
  3. I added a py.typed marker file, which is required for type hinted packages.
  4. I've also included a refactoring commit to get rid of the object inheritance (which isn't required, I believe, since Python 3).

Please note that I had to introduce a breaking change - the ttl parameter of on and on_any methods had to become a keyword argument, breaking callers who pass it as a positional argument. This way I could make use of @overload to more accurately describe signatures both for decorated and non-decorated usage.

Klavionik avatar Sep 07 '24 18:09 Klavionik