[New-bugs-announce] [issue28861] Type Hints Syntax

YoSTEALTH report at bugs.python.org
Sat Dec 3 15:48:45 EST 2016


New submission from YoSTEALTH:

Type Hints Syntax
-----------------

Goal: Is to make it easy to read function/methods arguments, yet keep the new and cool Type Hints.

For example this is a code from one of my function. Its getting to that point of what the heck is going on here?

def find_replace(string: str, find: (str, dict, list, tuple, set), replace: (str, list, tuple, set)='') -> str:
    pass

I know it can be rewritten as:

T = (str, dict, list, tuple, set)
def find_replace(string: str, find: T, replace: T='') -> str:
    pass

But when you start using variable to represent another variables type... maybe we are losing the plot here!

What if we could have both? Readability and type reference, what if it could be written as:

def find_replace(string, find, replace):
    targ str, *(str, dict, list, tuple, set) -> str
    # code here ...

targ = type argument (like *args and **kwargs)

Calling a "targ" like we call "global" but to represent types.

Simple Examples:

def Redirect(url='', code=301):
    targ (str, int) -> None


Just think about it...

----------
messages: 282304
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Type Hints Syntax
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28861>
_______________________________________


More information about the New-bugs-announce mailing list