A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/typing/issues/482 below:

Mixing typing and non-typing information in annotations · Issue #482 · python/typing · GitHub

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?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4