Uh oh!
There was an error while loading. Please reload this page.
fix: revise and rename is_etag_in_json(data) - #483
Conversation
Uh oh!
There was an error while loading. Please reload this page.
tritone
left a comment
There was a problem hiding this comment.
Looks much cleaner, thank you!
| pass | ||
| return False | ||
| :type data: dict or None | ||
| :param data: A dict containing the JSON body. If not passed, returns False. |
There was a problem hiding this comment.
Nit: I think we could be clearer that the dict represents the JSON body rather than containing it. Also, this is specifically intended for calls where metadata is sent in the request body.
It seems like it'd be better to actually just rename this function to is_etag_in_data but I guess technically this is part of the public surface of the library (even if we don't expect external callers to use it directly)?
There was a problem hiding this comment.
We could rename it and leave is_etag_in_json around as a backward-compatibility alias.
There was a problem hiding this comment.
Would it be something like this:
def is_etag_in_data(data):
"""Return True if an etag is contained in the request body.
:type data: dict or None
:param data: A dict representing the request JSON body. If not passed, returns False.
"""
return data is not None and "etag" in data
def is_etag_in_json(data):
"""
``is_etag_in_json`` is supported for backwards-compatibility reasons only;
please use ``is_etag_in_data`` instead.
"""
return is_etag_in_data(data)
Uh oh!
There was an error while loading. Please reload this page.
* fix: handle cases where data is a dict in is_etag_in_json(data) * address comments and accept proposed changes * revise is_etag_in_json to check dict data * revise docstring wording * revise docstrings * rename conditional predicate to is_etag_in_data
* fix: handle cases where data is a dict in is_etag_in_json(data) * address comments and accept proposed changes * revise is_etag_in_json to check dict data * revise docstring wording * revise docstrings * rename conditional predicate to is_etag_in_data
This PR revises and renames
retry.is_etag_in_json(data)to ensure that eTags are correctly captured and validated from the request body.retry.is_etag_in_json(data)toretry.is_etag_in_data(data). It returns a boolean whether or not anetagis contained in the request body.retry.is_etag_in_data(data)to reflect library use cases in whichdataisdictorNoneFixes#481 🦕