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

.add_argument() should also add kwargs to callsites #95

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ajberchek
Copy link
Contributor

.add_argument() should also have the ability to add kwargs to callsites to perform codemods where a callsite's kwarg differs from the function definition's default for that arg.

The doc for this specific modifier has been updated to remove the distinction between positional and keyword args since both types can be added to the function definition and the callsites in this PR.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jun 30, 2019
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@amyreese amyreese requested a review from thatch July 10, 2019 22:08
@amyreese
Copy link
Contributor

I'm not certain what this is getting us. If you're adding a keyword argument to the definition, there's no need to add it to the callers (in the current implementation) because the value will be the same. If the goal is to be able to use the is_call() and is_def() filters to make this actually useful (one pass to add argument to def, second pass to add argument to callers), then we should also improve this modifier to look for cases where these arguments already exist.

@ajberchek
Copy link
Contributor Author

It is the latter case.

The specific way I used this during my codemods was to add a value, different than the function's default, to a callsite and avoid needing to provide the positional args in between.

Good point about looking for arguments that already exist; I will update this PR to account for that.

@ajberchek
Copy link
Contributor Author

Functionality has been added to avoid adding an argument if it is already present in function definitions, and callsites for both positional and kwarg.

@thatch
Copy link
Contributor

thatch commented Mar 10, 2020

I squashed the history a little, this should be in a state to review now @jreese

@thatch
Copy link
Contributor

thatch commented Mar 10, 2020

This is on top or PR 102, I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants