Recently I had a typehint problem for which the only solution I found is to make the typehint as a string:
import pandas as pd
def fun() -> pd.Series[str]: # returns an ERROR
return pd.Series(['hola'])
def fun() -> "pd.Series[str]": # Does work and the IDE gets that whatever inside the series is a str
return pd.Series(['hola'])
The solution was here: How to specify the type of pandas series elements in type hints?
However I didn't find any useful documentation not in pep nor in the python docs explaining this form of typehints as a string and why the first solution doesn't work but the second does.
In the docs they appear twice (typing.self, typing.TypeVarTuple chapters), but it is not explained how are they evaluated differently. Anyone knows why is like that? or where is this documented in the docs / pep? Or how is this feature called?