coady / multimethod

Multiple argument dispatching.
https://coady.github.io/multimethod
Other
277 stars 24 forks source link

Make a program using @multimethod checkable with Mypy #11

Closed zhihaoy closed 4 years ago

zhihaoy commented 4 years ago

You may need to type annotate the package itself. Or to make it work with @overload in some way.

coady commented 4 years ago

Are you referring to error: Name 'func' already defined? That can be disabled in mypy configuration: # type: ignore[no-redef]. Alternatively, the register method can also be used:

@amethod.register
def _(...):
zhihaoy commented 4 years ago

Are you referring to error: Name 'func' already defined? That can be disabled in mypy configuration: # type: ignore[no-redef].

I mean this doesn't work. Where are the stubs files for this project?

If you have any solution, we should document it.

coady commented 4 years ago

Stub files aren't necessary since the project already has type hints. c52967c added the py.typed file so that mypy would recognize it.

For the already defined error, there isn't much that can be done. The README mentions it now, and #12 is opened to consider encouraging using register as the preferred style.