This is how far I got with this,
https://gist.github.com/jarradh/02dd8f5ad07527c9fd10

In the example go through Arguments(i imagine I'll have to apply
transform on functiondef later) and apply an explicit transformation,
and I manage to apply a Const type to all of them but I got stuck at
how to switch based on node._annotype.name
since Const instantiates with the name as a value and therefore it's a
string type.

How can I switch the Const type based on node._annotype.name ?
Or is there a better way of going about this?


On Tue, Apr 28, 2015 at 1:55 PM, Claudiu Popa <pcmantic...@gmail.com> wrote:
> On Tue, Apr 28, 2015 at 9:03 AM, Jarrad Hope <m...@jarradhope.com> wrote:
>> Hello
>>
>> Been using astroid extensively this past week, really enjoying it! Great 
>> work!
>
> Thank you.
>
>>
>> What's the best way I can deliberately set the type of an argument,
>> based on the function annotations?
>
> Currently we don't have any mechanism for this (but it is something
> that we want). One way to do it would be to add a Transform in
> astroid.brain for Function nodes, which checks that it has
> annotations, infers them and replaces the default inference with that
> one.
_______________________________________________
code-quality mailing list
code-quality@python.org
https://mail.python.org/mailman/listinfo/code-quality

Reply via email to