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 — bpo-43224: Implement PEP 646 grammar changes by mrahtz · Pull Request #31018 · python/cpython Conversation
|
|
@mrahtz Could you please add some expected syntax errors to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sure, will do. Two questions:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
If you want to check that something is a Syntax error and just want to assert the message and can do they with a simple input, in th doctest. If you required special compilation modes, some gigantic or dynamic string or check the location of the errors, then a specific test case is needed.
In general we have one test file for testing the runtime implications of the grammar, and things go to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry for the slow reply - I'm only just now finding time again to work on this. Looking through |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@pablogsal Friendly poke :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@pablogsal Another friendly poke :) I'm getting a bit nervous we might miss the merge window for 3.11 on this - if you're busy at the moment, would you be able to recommend anyone else who'd be a good fit for a review of this? (Or @JelleZijlstra do you know of anyone?) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Maybe @isidentical if you'd like to take a look? Seems like Pablo already looked at the diff to some extent, so if he doesn't have time for a full re-review, I can also do a review and help get this in. I'd of course prefer if someone familiar with the parser can do a review, though. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I noticed that this is allowed by the grammar: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Apologies, unfortunately I was sick with COVID these past weeks and I couldn't dedicate much time to open source :( I will do another pass today or tomorrow. Thanks for your understanding @mrahtz |
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.
Seems like ast.unparse is broken on some scenerious:
import ast tree_1 = ast.parse("A[1:2, *l]") tree_2 = ast.parse(ast.unparse(ast.parse(tree_1))) assert ast.dump(tree_1) == ast.dump(tree_2)
I assume it this is related to parenthesizing logic in here, which needs to be adapted to PEP646:
Lines 1479 to 1487 in ef1327e
| def is_simple_tuple(slice_value): | |
| # when unparsing a non-empty tuple, the parentheses can be safely | |
| # omitted if there aren't any elements that explicitly requires | |
| # parentheses (such as starred expressions). | |
| return ( | |
| isinstance(slice_value, Tuple) | |
| and slice_value.elts | |
| and not any(isinstance(elt, Starred) for elt in slice_value.elts) | |
| ) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I just fixed a merge conflict and a whitespace issue found by (1) The (2) There is also a C version of (3) If you use Here's an example that demonstrates these issues: Detailsfrom __future__ import annotations import typing import ast Ts = typing.TypeVarTuple("Ts") def f(x: tuple[*Ts], *args: *Ts): pass print(f.__annotations__) print(ast.unparse(ast.parse("tuple[*Ts]"))) print(typing.get_type_hints(f)) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Also, there were a few buildbot failures when Pablo triggered builds on 1543785, but apart from the whitespace issue I fixed, they looked like random failures on unrelated tests. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks, go ahead, but do add the needed tests and fix the issues. Agreed on the parsing in get_type_hints. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @mrahtz for the fixes! I'll do another review today or maybe tomorrow and then hopefully merge. I think we can leave the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@JelleZijlstra Oops, I only just saw your message 😅 Let me know if you'd prefer to take the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
If you already implemented it, that's fine too :) Thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| scope = {} | ||
| exec( | ||
| "from __future__ import annotations\n" | ||
| + code, {}, scope |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I removed this because if both globals and locals are passed to exec, it treats the code as it if were executed in a class definition, which makes the new test I've added harder than it needs to be (we can't access c so easily). Removing this doesn't seem to break any of the rest of the tests, so I hope this is fine?
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.
|
Whoop whoop! :D |
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.