-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
black/parser: partial support for pattern matching #2586
black/parser: partial support for pattern matching #2586
Conversation
FWIW I can't get this valid code to parse under this PR: value = (1, 2)
match value:
case x, y:
pass |
And of course CI is also broken due to recent changes in some third party packages, sigh. |
I've not included the 3.10 grammar among the default ones, since it is pretty experimental at the moment (and might have other, unknown problems). But it can be activated through specifying |
There's multiple layers to it (none which are your fault). A recent release of coverage broke the coverage upload step of the test jobs, a recent change in hypothesis makes our primer configuration broken currently, and finally my Python two deprecation code doesn't withstand parser changes well, should be fixed by #2592. p.s. I'm writing on a phone so my apologies for the terseness |
Is this something I should know about as Hypothesis dev? (also I love pinning deps with |
@Zac-HD oh don't worry about it! We have a development tool called black-primer and its job to run Black over millions of lines of code (by formatting a large array of OSS projects) to assure it doesn't crash or do other weird stuff. Hypothesis happens to be one of the projects and it seems like one of your in-tree development tools was recently made Python 3.8<= which broke the primer workflow on 3.7 and below. I've already fixed by marking Hypothesis as a 3.8+ project in the primer config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exciting!
If I remember correctly this also makes parenthesized with statements work thanks to parser magic. Should we add tests for that?
Ah, yep, the Array API standard requires Python 3.8+ and therefore our new extension for it does too. |
e046c14
to
d16f6c7
Compare
Co-authored-by: Richard Si <[email protected]>
d16f6c7
to
49096af
Compare
Added tests for that, nice catch! I'll also work on some more patterns for the PEP 634 in the upcoming PRs, but hopefully as is this PR should cover some of the basic cases for both of them. (not sure if there is anything else needed for the context managers). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome to see 3.9 and 3.10 compatibility truly realized, thank you!
Is more work needed here, or can this PR be merged? |
Partial implementation for #2242. Only works when explicitly stated -t py310. Co-authored-by: Richard Si <[email protected]>
The built-in lib2to3 does not support pattern matching (Python 3.10+): https://docs.python.org/3.11/library/2to3.html#module-lib2to3 The [black][] project managed to get some level of parsing support for `match` out of their modified version `blib2to3`, see: 1. psf/black#2242 2. psf/black#2586 [black]: https://github.com/psf/black This change adds `black` as a dependency and switches to using `blib2to3` to parse. Tests pass, but that's all that's been attempted thus far.
The built-in lib2to3 does not support pattern matching (Python 3.10+): https://docs.python.org/3.11/library/2to3.html#module-lib2to3 The [black][] project managed to get some level of parsing support for `match` out of their modified version `blib2to3`, see: 1. psf/black#2242 2. psf/black#2586 [black]: https://github.com/psf/black This change adds `black` as a dependency and switches to using `blib2to3` to parse. Tests pass, but that's all that's been attempted thus far.
The built-in lib2to3 does not support pattern matching (Python 3.10+): https://docs.python.org/3.11/library/2to3.html#module-lib2to3 The [black][] project managed to get some level of parsing support for `match` out of their modified version `blib2to3`, see: 1. psf/black#2242 2. psf/black#2586 [black]: https://github.com/psf/black This change adds `black` as a dependency and switches to using `blib2to3` to parse. Tests pass, but that's all that's been attempted thus far.
) * Use blib2to3 parser to support match statement The built-in lib2to3 does not support pattern matching (Python 3.10+): https://docs.python.org/3.11/library/2to3.html#module-lib2to3 The [black][] project managed to get some level of parsing support for `match` out of their modified version `blib2to3`, see: 1. psf/black#2242 2. psf/black#2586 [black]: https://github.com/psf/black This change adds `black` as a dependency and switches to using `blib2to3` to parse. Tests pass, but that's all that's been attempted thus far. * Add a _unreleased changelog for blib2to3 integration * fix mypy in docspec/src/docspec/__init__.py * fix mypy * update changelog format * update GitHub workflow * fix workflow * insert PR url * use `--no-venv-check` also for `slap run` in docs job --------- Co-authored-by: Niklas Rosenstein <[email protected]>
Partial implementation for #2242. Only works when explicitly stated
-t py310
.