Title: Don't return implicit optional types by get_type_hints
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.8, Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, levkivskyi
Priority: normal Keywords:

Created on 2018-03-24 18:16 by levkivskyi, last changed 2018-03-25 09:21 by levkivskyi.

Messages (3)
msg314378 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2018-03-24 18:16
Currently this code

def f(x: int = None):


returns {'x': Optional[int]}. I propose to abandon this behaviour. Although there is not yet a definitive decision about this aspect of PEP 484, see, I think at least at runtime we should not do this.
msg314395 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-03-25 05:39
I'm not sure we should change this ahead of a definitive decision. When you use mypy with the option that forbids it, your program will be invalid, and it doesn't really matter what we do at runtime; but that option is not the default yet, and without that option, mypy treats the type as Optional[int].
msg314401 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2018-03-25 09:21
OK, let us then keep this issue as a remainder that we need to update the runtime behaviour when the static one changes.
Date User Action Args
2018-03-25 09:21:10levkivskyisetmessages: + msg314401
2018-03-25 05:39:44gvanrossumsetmessages: + msg314395
2018-03-24 18:16:02levkivskyicreate