Constrain calling convention for PyStub #5761
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are two calling conventions that are sensible when calling a Generator from Python:
However, the current PyStub implementation also allows for mixing positional and keyword forms of input (as long as no input is specified multiple times). This change removes that possibility (requiring either all-keyword or all-positional for inputs). I'm not sure why I thought this was a good option originally, but upon reflection (and examination of existing code), calls written in this way tend to be a confusing mess that require too much care when reading, and I think we'd be better off just forbidding this entirely.
Note that this technically is a breaking API change (thus the
release_notes
label); any user code that used this technique previously would now throw an exception and need a (trivial) update. That said, this is (AFAIK) a very rarely used API, and I rather suspect that existing code that relies on being able to mix positional and keyword inputs in this way is likely to be doing so inadvertently rather than deliberately.