Jordan
12/15/2022, 10:55 AMREADME.md
files of my project. How should I document the type
of a partitioned dataset? Those function outputs need to be of the form dict[str, <type>]
, but when the dataset is loaded back it’s going to be dict[str, Callable[[], <type>]]
datajoely
12/15/2022, 10:57 AMDict[str, Union[Callable[[], Any]]]
Any
with pandas.DataFrame
or equivalentJordan
12/15/2022, 11:00 AMdatajoely
12/15/2022, 11:00 AMJordan
12/15/2022, 11:01 AMdict
now, right?datajoely
12/15/2022, 11:01 AMdict
works regardless but I’m not 100% sureDict[str, Callable[[] | Any]]
Jordan
12/15/2022, 11:02 AMdatajoely
12/15/2022, 11:02 AMJordan
12/15/2022, 11:02 AMdatajoely
12/15/2022, 11:02 AMDeepyaman Datta
12/15/2022, 10:28 PMdict
works without any extra imports since 3.9; you can also do from __future__ import annotations
for past versions. Callable
, if used, should have 0 or 2 arguments (list of inputs, output).