Add keyword arg guidelines to contrib doc #775
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.
In response to some discussion around
**kwargs
, we agreed that I should take a first crack at these guidelines.I tried to provide some context without lengthy exposition, and I've included a link to the PEP which introduced the
*
marker.One thing I debated, but decided against, was any note about "new functions" (vs in general) and the theme that these rules are broken not-infrequently for backwards compatibility. I think that's a given in any codebase with this level of history, so I opted to just make the blanket statements and trust that the compatibility concerns are implicitly clear.
Backwards compatibility around
**kwargs
capturingI avoided explaining in the text of the contrib doc, but, to illuminate the mention of "a class of backwards compatibility concerns", here's a bit of detail.
There are cases in which adding keyword arguments is not incompatible or not majorly so. This is completely compatible:
But there are simple cases in which it becomes nasty quickly. Here's a trivial-if-silly example:
Because this function was defined to capture all of
**kwargs
into a specific area of functionality, it's not possible to addc: int | None = None
as an item to include in thedata1
component.Avoiding
**kwargs
ensures that we don't find ourselves in this sort of unfortunate situation.📚 Documentation preview 📚: https://globus-sdk-python--775.org.readthedocs.build/en/775/