Implement inference for JoinedStr and FormattedValue#2459
Conversation
astroid/nodes/node_classes.py
Outdated
| if node is util.Uninferable: | ||
| result += "{Uninferable}" |
There was a problem hiding this comment.
It feels like we should exit early here and not continue to product "half" matching values
There was a problem hiding this comment.
That's philosophical, depending on the strategy for dealing with partially inferred collections of values
There was a problem hiding this comment.
It would help to make a decision about this if we could see a test case. At the moment, I do not think we should manufacture a constant that would never exist at runtime with the substring "Uninferable" in it.
There was a problem hiding this comment.
There's "coincidental" coverage of this line in test_typing_extensions_types based on the current implementation of typing, but it would be better to have explicit coverage.
There was a problem hiding this comment.
I agree with Jacob. I think Uninferable makes sense to those that have worked on astroid and pylint, but this will also be shown to users who might have no idea what it means. I would be in favour of exiting early and not creating partially correct values.
There was a problem hiding this comment.
It is useful to know which fragment(s) of a JoinedStr cause inference failure, but I agree that half-baked strings can be puzzling.
JoinedStr and FormattedValue
jacobtylerwalls
left a comment
There was a problem hiding this comment.
Thanks for contributing this feature!
astroid/nodes/node_classes.py
Outdated
| if node is util.Uninferable: | ||
| result += "{Uninferable}" |
There was a problem hiding this comment.
It would help to make a decision about this if we could see a test case. At the moment, I do not think we should manufacture a constant that would never exist at runtime with the substring "Uninferable" in it.
astroid/nodes/node_classes.py
Outdated
| if node is util.Uninferable: | ||
| result += "{Uninferable}" |
There was a problem hiding this comment.
There's "coincidental" coverage of this line in test_typing_extensions_types based on the current implementation of typing, but it would be better to have explicit coverage.
for more information, see https://pre-commit.ci
…ue' of github.com:ericvergnaud/astroid into support-value-inference-for-joinedstr-and-formatted-value
…ue' of github.com:ericvergnaud/astroid into support-value-inference-for-joinedstr-and-formatted-value # Conflicts: # ChangeLog
|
Great work ! |
|
Oh, I just saw the failing tests. I do think we need to address it. |
|
It's failing on main too, we've merged multiple MR with 3.13 failing in the last week. (Due to a New beta of python 3.13). I think we could (should?) fix it before astroid 3.3.0 release. |
TBH I'm 100% sure that the failure is unrelated to this PR. The test simply calls |
|
It's fixed in the 3.13rc1, which may not be on GH yet. |
|
See #2478 |
Type of Changes
Description
node.inferred()would returnUninferableif inference involved aJoinedStr.JoinedStrinvolvesFormattedValueso this is addressed for both classes in the same PR