Search code examples
mypy

Type lookup or type alias references in mypy


I have a function as follows:

def a():
  return b()

What I want is either:

def a() -> ReturnType[typeof b]:
  return b()

or... the original example with the return type fully inferred.

I searched the mypy docs and poked inside of the typing module. I'm unclear if this is feasible. Let me know! Thanks


Solution

  • Per @motto above, this is not supported. See https://github.com/python/mypy/issues/8385