Answer the question
In order to leave comments, you need to log in
What is the best way to organize a function call in python with type typing?
Hello, I am writing a wrapper over vk api for python. I want to make full type typing for all functions and objects of VK, as well as for VK api methods and their responses.
the question arose about the convenience of such a format. Data typing is certainly good, but it makes the code too cumbersome. For example, a function to call groups with the "filter" parameter will have to be done like this:
vk.groups.get(filter=GroupsFilter.ADMIN)
>>> {'response': {'count': 0, 'items': []}}
class GroupsFilter(Enum):
ADMIN = 'admin'
EDITOR = 'editor'
MODER = 'moder'
GROUPS = 'groups'
PUBLICS = 'publics'
EVENTS = 'events'
HAS_ADDRESSES = 'has_addresses'
vk.groups.get(filter='admin')
>>> {'response': {'count': 0, 'items': []}}
Answer the question
In order to leave comments, you need to log in
You can also use typing.Literal, but you can't count on PyCharm support.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question