Reputation: 95
I'm not sure the documentation contains any concrete info on the type of view objects. I wasn't able to locate it (i.e. <class 'dict_values'>
in the dict's source code. Is there a way to explicitly specify this 'view class'? And does it make sense in the first place? Example:
def func1(arg: dictview) -> None:
pass
Upvotes: 4
Views: 937
Reputation: 16546
typing.MappingView
is now deprecated in python 3.9 , You can use collections.abc.MappingView
collections.abc.MappingView
collections.abc.ItemsView
collections.abc.KeysView
collections.abc.ValuesView
Upvotes: 2
Reputation: 522522
You're looking for the typing.MappingView
type hint or any of its related types like KeysView
, ItemsView
, ValuesView
.
Upvotes: 6