1

I am trying out the Python 3 type hinting with this example:

from typing import List

def greeting(names: List[str]) -> str:
        return 'Hello, {}'.format(', '.join(names))

greeting(['jane', 'john', 'judy'])    


greeting([1,2,3])

What I should see is an error on the last method call, but no error on the first. However, on both I see the error deferred error : (error "\"TypeError('expected string or buffer',)\"")

Is there another package that can do type hinting/way I can fix Jedi here?

3
  • Have you considered filing an issue against the jedi repository?
    – PythonNut
    Commented Feb 7, 2016 at 1:51
  • @PythonNut I want to make sure that this is something other people have seen/see if there is a way around it first before bugging them about it
    – Andrew
    Commented Feb 7, 2016 at 17:57
  • Are you running the Jedi server under Python 3?
    – Qudit
    Commented May 4, 2018 at 7:37

1 Answer 1

0

I'm not sure what the issue with Jedi is but using flycheck, I managed to get it to play nice with type hints by adding the mypy as a checker and enabled the python executable to be python3. I'm a spacemacs user so the config might differ a bit but here is what works for me below.

  (flycheck-define-checker
  python-mypy ""
  :command ("mypy"
            "--ignore-missing-imports" "--fast-parser"
            "--python-version" "3.6"
            source-original)
  :error-patterns
  ((error line-start (file-name) ":" line ": error:" (message) line-end))
  :modes python-mode)
  (add-to-list 'flycheck-checkers 'python-mypy t)
  (flycheck-add-next-checker 'python-pylint 'python-mypy t)
  (setq flycheck-python-pycompile-executable "/usr/bin/python3")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.