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

Support **$... for keyword arguments. #102

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Sep 25, 2023

Support **$... for keyword arguments.

This pretty much just works out of the box, albeit it's ordering-dependent.

For instance, to match any call to foo.Bar which does not include dry_run=True, you can use:

AllOf(
  ExprPattern("foo.Bar(*$..., **$...)"),
  Unless(ExprPattern("$_(*$..., **$..., dry_run=True, **$...)"))
)

Or similar.

A future change to refex (which I do want to make eventually...) could eventually mean keyword parameter and dict ordering is ignored by default, so that we can remove one of the **$....

This pretty much just works out of the box, albeit it's ordering-dependent.

For instance, to match any call to `foo.Bar` which does _not_ include `dry_run=True`, you can use:

```python
AllOf(
  ExprPattern("foo.Bar(*$..., **$...)"),
  Unless(ExprPattern("$_(*$..., **$..., dry_run=True, **$...)"))
)
```

Or similar.

A future change to refex (which I do want to make eventually...) could eventually mean keyword parameter and dict ordering is ignored by default, so that we can remove one of the `**$...`.

PiperOrigin-RevId: 568317030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant