-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Description
First of all apologies if this is not the right project to post this question.
Sometimes one needs to annotate parameters and/or return values with not only types but some other information as well (an information that could be used at runtime).
The example below should show what I'm thinking about and what kind of API I have in mind:
# 1. mix (for the lack of a better name) is an imaginary construct that can combine
# type and non-type annotations
from library import some_marker
def function(d: mix[Dict[int, str], some_marker], i: int) -> str:
# ...
# 2. get_type_hints is modified to only return type-related information (the first
# argument to mix for the sake of simplicity)
get_type_hints(function) == {'d': Dict[int, str], 'i': int, 'return': str}
# 3. get_nontype_annotations /for the lack of a better name/ function is introduced
get_nontype_annotations(function) == {'d': some_marker, 'i': None, 'return': None}
I apologise if there was a discussion about something like this already, I haven't found any. What do you think about this particular need? There's no simple way to achieve anything similar right now, is there?
Metadata
Metadata
Assignees
Labels
No labels