[Python-ideas] Lessons from typing hinting Whoosh (PEP484)
Sven R. Kunze
srkunze at mail.de
Mon Nov 16 11:33:53 EST 2015
Or like structural typing - there has already been some discussion on
this list:
https://github.com/ambv/typehinting/issues/11#issuecomment-138133867
On 16.11.2015 07:51, Vito De Tullio wrote:
> Matt Chaput wrote:
>
>> 2. It would be really nice if we could have "type aliasing" (or whatever
>> it's called). I have a lot of types that are just something like
>> "Tuple[int, int]", so type checking doesn't help much. It would be much
>> more useful if I have a value that Python sees as (e.g.) an int, but have
>> the type system track it as something more specific. Something like this:
>>
>> DocId = typing.TypeAlias(int)
>> DocLength = typing.TypeAlias(int)
>>
>> def id_and_length() -> Tuple[DocId, Length]:
>> docid = 5 # type: DocId
>> length = 10 # type: Length
>> return docid, length
> like... type aliases? https://www.python.org/dev/peps/pep-0484/#type-aliases
>
More information about the Python-ideas
mailing list