Skip to content
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

Python: Add support for type parameter defaults #17688

Merged
merged 11 commits into from
Oct 15, 2024

Conversation

tausbn
Copy link
Contributor

@tausbn tausbn commented Oct 8, 2024

Adds support for the new syntax for default values for type parameters, as documented in PEP-696.

Pull Request checklist

All query authors

Internal query authors only

  • Autofixes generated based on these changes are valid, only needed if this PR makes significant changes to .ql, .qll, or .qhelp files. See the documentation (internal access required).
  • Changes are validated at scale (internal access required).
  • Adding a new query? Consider also adding the query to autofix.

@github-actions github-actions bot added the Python label Oct 8, 2024
@tausbn tausbn force-pushed the tausbn/python-3.13-default-type-parser-support branch from cdd7e2d to f2d2411 Compare October 9, 2024 13:16
@tausbn tausbn force-pushed the tausbn/python-3.13-default-type-parser-support branch from 58a4698 to 8d41922 Compare October 9, 2024 20:21
@tausbn tausbn marked this pull request as ready for review October 9, 2024 20:21
@tausbn tausbn requested a review from a team as a code owner October 9, 2024 20:21
@tausbn tausbn added the Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish label Oct 9, 2024
@tausbn tausbn force-pushed the tausbn/python-3.13-default-type-parser-support branch 2 times, most recently from fe15ce6 to ba03d92 Compare October 11, 2024 12:59
yoff
yoff previously approved these changes Oct 11, 2024
Copy link
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

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

LGTM

Also fixes an oversight in the grammar: starred expressions should be
allowed inside the subscript of an `Index` expression.
Two new files -- alloc.h and array.h -- suddenly appeared. Presumably
they are used by the somewhat newer version of tree-sitter. To be safe,
I included them in this commit.
There was an errant `ql` in the relevant paths, a leftover from the move
from the internal repo. Also, we can no longer rely on an intree version
of the CodeQL CLI, so from now on we'll just assume it's present in the
path. (On Codespaces, `gh codeql` is a decent replacement, especially if
using the `install-stub` functionality.
Note that this still includes the somewhat puzzling parsing of
`Spam[**P2]` as an exponentiation with an empty left hand side. When we
fix that bug, we should also update this test to contain actually valid
syntax.
Adds up- and downgrade scripts for the support for type parameter
defaults.

In the upgrade direction we do nothing, matching the behaviour of
`getDefault` not having a result for old databases.

In the downgrade direction, we explicitly remove the relevant child (via
the `py_exprs` database relation) for `TypeVar`, `TypeVarTuple`, and
`ParamSpec` parameters.
@tausbn tausbn force-pushed the tausbn/python-3.13-default-type-parser-support branch from ba03d92 to 417e60a Compare October 15, 2024 11:23
@tausbn tausbn requested a review from yoff October 15, 2024 12:33
@tausbn
Copy link
Contributor Author

tausbn commented Oct 15, 2024

Had to fix up the commit message for the upgrade scripts (as it was now misleading) and rebase so that I could update the extractor version, hence the need to re-review. Apart from that, there are no changes compared to what was reviewed previously.

Copy link
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

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

LGTM

@tausbn tausbn merged commit 28f8874 into main Oct 15, 2024
15 checks passed
@tausbn tausbn deleted the tausbn/python-3.13-default-type-parser-support branch October 15, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish documentation Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants