-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recursive resolving of type aliases #67
Comments
What you are suggesting is indeed the current way to do it. I see how what you're asking for could be useful, but there's a couple of complexities:
A solution could be to add a new higher-level representation of types to typeshed-client, a set of classes like the ones in https://github.com/quora/pyanalyze/blob/master/pyanalyze/value.py or https://github.com/python/mypy/blob/master/mypy/types.py. |
Thank you for the fast response. I mostly wanted to know if I was in the right track, so this is already great information. I completely agree with your points, which completely rules out replacing ASTs. But how about an additional element in the tuple (only available if requested), say called Anyway, since currently |
@JelleZijlstra I implemented what I needed, see jsonargparse/_stubs_resolver.py. I am not sure if there is something that would be worth contributing back here. If you want an explanation of what the code does, let me know. If not, we could close this issue. A couple additional comments.
|
typeshed_client
seems the right fit for a project I am working on, though I am still trying to figure out how it is supposed to be used, and how to make it work for my case. I want to get the types of the parameters of some function. These types can have aliases in them, but I want to resolve them to basic python types or types defined in the respective python modules.Say for example that I want the types for
requests.get
. First create a virtual environment:python3.10 -m venv venv . venv/bin/activate pip install requests types-requests typeshed-client
Then in python:
Note the type aliases
_Params
,_Data
,_HeadersMapping
,_TextMapping
,_HooksInput
,_Verify
. I can look at the AST to figure out undefined names and then try to get them, but this seems to be something that should be part of a library:Now new aliases
_ParamsMappingKeyType
,_ParamsMappingValueType
.Is there already a simpler way to achieve this? If not, would it make sense to extend
typeshed_client
to make this easy? One idea could be to have an option such thatrequests_api_get.ast
already has all the type aliases are replaced with the respective ASTs. Alternatively (though less convenient) have the alias ASTs inchild_nodes
or in a separate element of the named tuple.The text was updated successfully, but these errors were encountered: