Using Python 3's function annotations, it is possible to specify the type of items contained within a homogeneous list (or other collection) for the purpose of type hinting in PyCharm and other IDEs?
A pseudo-python code example for a list of int:
def my_func(l:list<int>):
pass
I know it's possible using Docstring...
def my_func(l):
"""
:type l: list[int]
"""
pass
... but I prefer the annotation style if it's possible.
type object is not subscriptable
when defining the function. Obviously you can use a string:def my_func(L: 'list[int]')
but I don't know whether PyCharm will parse it as it parses the docstrings...'list[int]'
, apologies if that wasn't clear.