Problem with mypy not type checking overload functions correctly due to missed signatures

October 3, 2022

Link:

https://stackoverflow.com/a/57225493

Overview:

  • if a function has multiple possible invocation signatures, you may add a typing overload to help mypy understand the difference
  • however, you may receive an error because if you pass in positional arguments, mypy will not be able to determine which overload to use
  • solution is to enforce keyword arguments, this way each argument passed in will be matched to the correct overload