You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add globalns and localns to the inspect.signature and inspect.Signature.from_callable #86126
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2020-12-23.22:45:52.586>created_at=<Date2020-10-06.20:39:01.138>labels= ['type-feature', 'library', '3.10']
title='Add globalns and localns to the inspect.signature and inspect.Signature.from_callable'updated_at=<Date2020-12-23.22:45:52.585>user='https://github.com/isidentical'
It's been a while, I've lost context for this idea. What problem are you trying to solve here? Are there issues where people have reported problems that this would allow them to solve?
It's been a while, I've lost context for this idea. What problem are you trying to solve here? Are there issues where people have reported problems that this would allow them to solve?
Normally, if inspect.signature is able to resolve annotations with the current globals()/locals() it will give the resolved version, if not the string version. So adding this would allow people to choose which namespace inspect.signature will pass to the typing.get_type_hints. (inspect.signature(foo, localns=locals()) would give directly the F object instead of 'F', etc.)
New changeset eee1c77 by Batuhan Taskaya in branch 'master': bpo-41960: Add globalns and localns parameters to inspect.signature and Signature.from_callable (GH-22583) eee1c77
Activity
isidentical commentedon Oct 6, 2020
To resolve annotations in local namespaces (and possibly in different contexts), inspect.signature can take globalns and localns parameters.
I'm not inclined to add these into the getfullargspec, but I'd appreciate any comments about whether it is a good idea or not!
gvanrossum commentedon Dec 17, 2020
It's been a while, I've lost context for this idea. What problem are you trying to solve here? Are there issues where people have reported problems that this would allow them to solve?
isidentical commentedon Dec 23, 2020
Context: #20434 (comment)
tl;dr:
import inspect
Normally, if inspect.signature is able to resolve annotations with the current globals()/locals() it will give the resolved version, if not the string version. So adding this would allow people to choose which namespace inspect.signature will pass to the typing.get_type_hints. (inspect.signature(foo, localns=locals()) would give directly the F object instead of 'F', etc.)
isidentical commentedon Dec 23, 2020
New changeset eee1c77 by Batuhan Taskaya in branch 'master':
bpo-41960: Add globalns and localns parameters to inspect.signature and Signature.from_callable (GH-22583)
eee1c77