I want to set the type of f
as typing.IO[typing.Any]
. The code below gets that done, but putting typing code in a comment rubs me wrong.
with open(cache_file) as f: # type: typing.IO[typing.Any]
cache_dict = json.load(f)
Is there any other syntax available for this situation where a colon immediately follows the variable I want to set the type for? I was hoping for something like this:
with open(cache_file) as f: typing.IO[typing.Any]:
cache_dict = json.load(f)