MCPcopy
hub / github.com/fastapi/fastapi / get_value_or_default

Function get_value_or_default

fastapi/utils.py:121–136  ·  view source on GitHub ↗

Pass items or `DefaultPlaceholder`s by descending priority. The first one to _not_ be a `DefaultPlaceholder` will be returned. Otherwise, the first item (a `DefaultPlaceholder`) will be returned.

(
    first_item: DefaultPlaceholder | DefaultType,
    *extra_items: DefaultPlaceholder | DefaultType,
)

Source from the content-addressed store, hash-verified

119
120
121def get_value_or_default(
122 first_item: DefaultPlaceholder | DefaultType,
123 *extra_items: DefaultPlaceholder | DefaultType,
124) -> DefaultPlaceholder | DefaultType:
125 """
126 Pass items or `DefaultPlaceholder`s by descending priority.
127
128 The first one to _not_ be a `DefaultPlaceholder` will be returned.
129
130 Otherwise, the first item (a `DefaultPlaceholder`) will be returned.
131 """
132 items = (first_item,) + extra_items
133 for item in items:
134 if not isinstance(item, DefaultPlaceholder):
135 return item
136 return first_item

Callers 4

for_includeMethod · 0.90
combineMethod · 0.90
from_api_routeMethod · 0.90
add_api_routeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…