Skip to content

Conversation

@copybara-service
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.

2 participants