Open pylint-bot opened 8 years ago
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: PCManticore):
This is something that will be part of a larger implementation for understanding flow control in astroid (https://bitbucket.org/logilab/astroid/issues/213/draft-a-plan-for-having-control-flow), but I think we can start having an implementation for IfExp before that, since the challenges that come with a flow control understanding (path sensitiveness and things like that) don't come up at all for this example. As an implementation, it could be similar to the implementation of the bool builtin (astroid.brain.builtin_inference): infer what the test returns, call the result's bool_value method and depending on its result, return either one or the other branch.
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: PCManticore):
If we can infer the test, why not choosing the one we know is going to be taken? If not, yes, we can return both of them.
Originally reported by: Laura Médioni (BitBucket: lmedioni, GitHub: lmedioni)
It would be good to have support for inference on an IfExp node.
For example:
An InferenceError is currently raised when calling inferred() on the right part of the assign node.