Provide a better comment for the object short-circuit

A previous commit was landed over a -1 from a core reviewer that was
concerned about the terse and flippant commit message that accompanied
the commit. The substance of that objection was that there was no good
explanation for why the change was made. Indeed, that why is likely
useful for people looking at the code too, so add a more complete
comment on the code in question.

Change-Id: I1ff777393502edf4ef3ed595e47bfcf73be0e5e8
This commit is contained in:
Monty Taylor 2015-12-02 06:07:38 -08:00
parent 07ac77ca76
commit dcdb20d0f5

View File

@ -121,11 +121,15 @@ def _get_entity(func, name_or_id, filters):
A function that takes `name_or_id` and `filters` as parameters
and returns a list of entities to filter.
:param string name_or_id:
The name or ID of the entity being filtered.
The name or ID of the entity being filtered or a dict
:param dict filters:
A dictionary of meta data to use for further filtering.
"""
# We've been passed a dict/object already, return it
# Sometimes in the control flow of shade, we already have an object
# fetched. Rather than then needing to pull the name or id out of that
# object, pass it in here and rely on caching to prevent us from making
# an additional call, it's simple enough to test to see if we got an
# object and just short-circuit return it.
if hasattr(name_or_id, 'id'):
return name_or_id
entities = func(name_or_id, filters)