GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||
GeezerVison is showing github.com — GH-94694: Fix column offsets for multi-line method lookups by brandtbucher · Pull Request #94697 · python/cpython Conversation
|
|
🤖 New build scheduled with the buildbot fleet by @brandtbucher for commit 33dc4d8 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def test_multiline_assert_rewritten_as_method_call(self): | ||
| # GH-94694: Copying location information from a "real" node to a | ||
| # handwritten one should always be valid! |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should it really always be valid?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I can remove the comment if it's too controversial. It just seems to me that the utility/safety of ast.copy_location and ast.fix_missing_locations is dramatically reduced if they can't at least promise crash-free behavior.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Is a bit unfortunate that we cannot just propagate correctly the offsets from the AST nodes. The disadvantage of a method relying on inspecting the source (here through the method name) is that ASTs created from abstract sources (or no source at all) may fall through the cracks in these kind of checks. What's preventing us from correctly grab the original column offsets from the multi line method call? (I know this has more to be with the original issue, but I would like to fully understand this before adding more band aids :) ) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The issue here is that we are flattening a multi line location into a single line. So we are trying to construct the location info for the attribute name only (which is not available directly in the AST, it seems). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
For our own nodes, I can fix that in the parser so our nodes make those available. For random AST nodes it may still be a problem. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think we almost have it. The location of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The pytest nodes are not completely random, if we copy to them the location of the attr name from the source code the traceback will probably look right - the source line from the file will appear with the right thing hilighted. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The root of the issue is that
Unfortunately, This also creates a weird (but probably fine) inconsistency. If the attribute access is all on one line, the whole thing is underlined in the traceback. If it spans multiple lines, only the attribute name is underlined. All this just comes from our need to trace the line that the attribute name is on, and trying (after the fact) to figure out what columns that should include. :( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This is exactly what I'm referring to. We could modify the AST to add this information so we don't need to guess. This way, it should also have work with arbitrary AST nodes. The price is that although this is something we can do, it will force everyone to adapt. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yeah. I think it would be an acceptable change for 3.12. While some consumers of the AST would need to change their code slightly, it wouldn't be removing any functionality that's currently present. If anything, it's adding functionality. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @brandtbucher for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, @brandtbucher, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think this one's gonna need a manual backport. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ps (pythonGH-94697). (cherry picked from commit 264b3dd) Co-authored-by: Brandt Bucher <[email protected]>
|
GH-94721 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.