I don't know annotation of the empty array by typing module.
Sometimes, I'm using the list as a container of data.
it's like
box = []
def fuga(box):
"""box is container of processed data in this function"""
for _ in range(10):
res = hoge(_) # API response
box.append(res)
return box
So far I wrote this code as following,
from typing import List
box = []
def fuga(box: list) -> List[str]:
for _ in range(10):
res: str = hoge(_)
box.append(res)
return box
It works well, but it's not appropriate python coding by typing module, I guess. This is because it's difficult for developer to understand what objects the variable "box" has. So, I think the appropriate annotation is
from typing import List
box = []
def fuga(box: List[None]) -> List[str]:
for _ in range(10):
res: str = hoge(_)
box.append(res)
return box
Is it collect or not? And if it's wrong, I want to know how to annotate empty array object as an argument.