-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Rename stripPrefix=
to strip_prefix=
#24019
Conversation
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.
If you really wish to change the builtin method annotation mechanism, you'd want to (1) add error handling for both old and new parameter names being used in the same call; (2) add error handling for an old parameter name matching either a current or old name of another parameter; (3) add tests to verify all above; (4) run a microbenchmark to check if performance was affected (since getParameterIndex is very frequently used iirc). This would be a lot of work - and it's not clear to me that the work would be worth it, considering that only 2 functions would benefit!
Instead, I'd suggest undoing the annotation changes, and simply adding an extra parameter to the 2 affected functions. Make the new param documented (but make sure to mention the old name in the doc string!), make the old param undocumented, and add a check to make sure that at most 1 of the two parameters is set.
2287b82
to
1de5ea0
Compare
There's been multiple PRs over the years to try fixing that issue by adding a new parameter:
Doing it with an alias might be slightly more lines of code, but the chances of success seem higher.
Done. The error checking was actually already there, but I added a test and ensured the error message would consistently refer to the current parameter name.
Done. There were no pre-existing checks for duplicate parameter names, so I figured the best spot to implement that would be in the annotation processor.
Done.
I adjusted the code so it'll only look for an old parameter name if one was detected at the time If more performance is needed in |
A linear search could very well be faster than a While this can all be ruled out by benchmarks, I also don't think that this migration is worth adding features to the Starlark interpreter. At some point, we may even want to get rid of the old parameter entirely, potentially backed by a The old PRs failed because they either weren't backwards compatible or failed to attract attention by reviewers. I can promise that won't happen this time. :-) |
1de5ea0
to
1d022f4
Compare
Today I learned that GitHub will automatically close pull requests if the author accidentally pushes without committing. Branch updated so it effects the rename using a new |
02305e9
to
4ed6fb1
Compare
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.
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.
Looks good, thanks!
I took the liberty of rewording the doc string addition a little bit, to mention that the old name may still be used but is now deprecated.
@meteorcloudy - I've imported the patch internally and sent it to you for review |
@bazel-io fork 8.0.0 |
Fixes bazelbuild#16496 Closes bazelbuild#24019. RELNOTES: The stripPrefix parameter of repository_ctx.download_and_extract() and repository_ctx.extract() has been renamed to strip_prefix; the deprecated stripPrefix name remains usable for compatibility. PiperOrigin-RevId: 687224164 Change-Id: Iffaba2e65c049a2ff8bb98d1fba52e0bba9e5a02
Fixes #16496 Closes #24019. RELNOTES: The stripPrefix parameter of repository_ctx.download_and_extract() and repository_ctx.extract() has been renamed to strip_prefix; the deprecated stripPrefix name remains usable for compatibility. PiperOrigin-RevId: 687224164 Change-Id: Iffaba2e65c049a2ff8bb98d1fba52e0bba9e5a02 Commit 49d7bb6 Co-authored-by: Alexandre Rostovtsev <[email protected]>
Fixes #16496