◐ Shell
reader mode source ↗
Skip to content

bpo-43897: Implement AST validation for Pattern Matching#24771

Merged
brandtbucher merged 1 commit into
python:mainfrom
isidentical:pattern-matching-validator
Jul 28, 2021
Merged

bpo-43897: Implement AST validation for Pattern Matching#24771
brandtbucher merged 1 commit into
python:mainfrom
isidentical:pattern-matching-validator

Conversation

@isidentical

@isidentical isidentical commented Mar 6, 2021

Copy link
Copy Markdown
Member

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 11, 2021
@isidentical isidentical changed the title bpo-42128: Implement AST validation for Pattern Matching Apr 20, 2021

@brandtbucher brandtbucher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

Hi @isidentical!

I think I missed this in the beta-freeze scramble. Any plans to update it for the new AST?

@isidentical

Copy link
Copy Markdown
Member Author

I think I missed this in the beta-freeze scramble. Any plans to update it for the new AST?

I might take a look at it in the upcoming weeks though I don't think I would have enough capacity to catch up with beta 2 (9 days from now). If you have time, I could give access to my fork if not I'll try to make it ready for beta 3.

@brandtbucher

Copy link
Copy Markdown
Member

Beta 3 is fine!

@isidentical isidentical force-pushed the pattern-matching-validator branch from 0356aea to d758c6a Compare June 12, 2021 17:43
@isidentical

Copy link
Copy Markdown
Member Author

Hey @brandtbucher! I've updated the PR with the new AST form, sorry it took a bit long. I didn't have much free time after the AST layout change, and needed to catch up with the new nodes first. Just ported all the missing pieces, there are still some bugs that I can see (for example some of the old parts of the validator code just quit when error happens, but doesn't decrement the recursion limit. Since I didn't touch those and the patch was already big I just skipped them now, might fix later) but nothing too big. Please let me know any missing stuff that I should handle.

@isidentical isidentical requested a review from brandtbucher June 12, 2021 17:46
@isidentical isidentical added 🔨 test-with-buildbots Test PR w/ buildbots; report in status section and removed stale Stale PR or inactive for long period of time. labels Jun 12, 2021
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @isidentical for commit d758c6a1e9f6c01800822c5bdf5e1778161fab3f 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 12, 2021
@isidentical isidentical requested a review from pablogsal June 28, 2021 07:33

@brandtbucher brandtbucher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

Thanks, this looks really good! I just have a few comments:

@bedevere-bot

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@brandtbucher

Copy link
Copy Markdown
Member

Just ported all the missing pieces, there are still some bugs that I can see (for example some of the old parts of the validator code just quit when error happens, but doesn't decrement the recursion limit. Since I didn't touch those and the patch was already big I just skipped them now, might fix later) but nothing too big.

Sorry, didn't see this. Feel free to ignore those suggestions, then!

I can find time to go back over those and fix the "_" name validation issue sometime if you're too busy. Just let me know.

@isidentical

Copy link
Copy Markdown
Member Author

I can find time to go back over those and fix the "_" name validation issue sometime if you're too busy. Just let me know.

What do you mean by the _ validation (example case would be welcome)? By the way feel free to apply style suggestions by yourself since it is quite hard to deal with that sort of diffs in GitHub interface :(

@brandtbucher

Copy link
Copy Markdown
Member

What do you mean by the _ validation (example case would be welcome)?

Patterns like MatchMapping(..., rest="_"), MatchStar("_"), and MatchAs(..., name="_") should be rejected, but aren't.

Also, MatchStar is allowed as a top-level pattern, but shouldn't be. I'll just merge this and fix those, the remaining recursion depth bugs, and remove some outdated comments in a new PR today (it will be easier to backport to 3.10 that way).

@brandtbucher brandtbucher merged commit 31bec6f into python:main Jul 28, 2021
@brandtbucher

Copy link
Copy Markdown
Member

Thanks again! Sorry I kept dropping the ball on this, haha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants