Consider the following python file test.py
:
def accepts_string(s: str):
pass
If I open a python shell, import this function and then grab the function's parameter s
and its annotation I get a string literal.
>>> import inspect
>>> from test import accepts_string
>>> inspect.signature(accepts_string).parameters['s'].annotation
'str'
However, if I define the function in the shell - I get the expected results of an actual "class type".
>>> import inspect
>>> def accepts_string(s: str):
... pass
...
>>> inspect.signature(accepts_string).parameters['s'].annotation
<class 'str'>
I would expect to always get the later results and I'm having trouble reconciling the different results based on whether the function is imported vs. defined live.