There is a discrepancy now between PEP 484 and PEP 526: def f(x: int = None): ... # OK x: int = None # Error
I think the two rules should be "in sync", in view of this I agree with the proposal. Concerning verbosity and a long name Optional there are many reasonable workarounds. One is already mentioned from typing import Optional as O. Another (unrelated to `` = None`` pattern) is https://github.com/python/typing/issues/420 that allows to avoid Optional altogether in patterns like this: def func(x: Optional[X]) -> Optional[Y]: if x is None: return None # do some stuff with 'x' With @maybe decorator proposed in https://github.com/python/typing/issues/420 this will be simplified to: @maybe def func(x: X) -> Y: if x is None: return None # do some stuff with 'x' Even if @maybe will not make it to typing, one still can define such (or similar) decorators (especially with @decorated_type and extended Callable syntax). In view of this, I think verbosity is not a problem at all. -- Ivan
_______________________________________________ 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/archive%40mail-archive.com