microsoft / knossos-ksc

Compiler with automatic differentiation
Other
45 stars 10 forks source link

RFC: Typecheck expr.py #902

Closed cgravill closed 3 years ago

cgravill commented 3 years ago

AB#19879 specifically AB#19886

Some good changes:

A change I'm not totally happy with:

The overall situation is that mypy has numerous limitations with functools.singledispatch see https://github.com/python/mypy/issues/8356

Suffixing the type onto the dummy method isn't the listed style for singledispatch, but seems common if you want to process your code by a type checker which is what I've done here. Tests and type checker pass, though I think it means the type checkers believe most of the implementations are dead code.

Alternatives:

cgravill commented 3 years ago

Long term (3.10) alternative https://www.python.org/dev/peps/pep-0636/#adding-a-ui-matching-objects

cgravill commented 3 years ago

Any thoughts on these @acl33 particularly the singledispatch?