Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

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

Open
ajberchek wants to merge 2 commits into
facebookincubator:mainfrom
ajberchek:master
Open

.add_argument() should also add kwargs to callsites#95
ajberchek wants to merge 2 commits into
facebookincubator:mainfrom
ajberchek:master

Conversation

@ajberchek

Copy link
Copy Markdown
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
Copy Markdown

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 cla@fb.com. 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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

thatch commented Mar 10, 2020

Copy link
Copy Markdown
Contributor

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

@thatch

thatch commented Mar 10, 2020

Copy link
Copy Markdown
Contributor

This is on top or PR 102, I believe.

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

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.

4 participants