This is my first post on this list, so please don't kill me if I       ask it in the wrong place, or if the question is stupid.

    


    

    

I asked this question on Stack Overflow already:

    

https://stackoverflow.com/questions/47163048/python-annotations-difference-between-tuple-and

    


    

    

In very short, which form is correct ?
    

    


    

    def func() -> Tuple[int, int]">

(original) (raw)



2017-11-08 14:01 GMT-08:00 Jean-Patrick Francoia <jeanpatrick.francoia@gmail.com>:

This is my first post on this list, so please don't kill me if I ask it in the wrong place, or if the question is stupid.


I asked this question on Stack Overflow already:

https://stackoverflow.com/questions/47163048/python-annotations-difference-between-tuple-and


In very short, which form is correct ?


def func() -> Tuple\[int, int\]





But this requires to import the typing module.





Or this (doesn't crash):





def func() -> (int, int):




The former is correct. Type checkers should reject the second one. But because type checking in Python is through static analysis, either will work at runtime—you need to run a separate static analysis tool like mypy or pytype to find type errors in your code.

Also, python-dev is a mailing list for the development of Python, not for questions about Python. The Gitter chatroom at https://gitter.im/python/typing and the typing issue tracker at https://github.com/python/typing are better places for questions about typing in Python.
_______________________________________________

Python-Dev mailing list

Python-Dev@python.org

https://mail.python.org/mailman/listinfo/python-dev

Unsubscribe: https://mail.python.org/mailman/options/python-dev/jelle.zijlstra%40gmail.com