MCPcopy
hub / github.com/pallets/click / iter_params_for_processing

Function iter_params_for_processing

src/click/core.py:138–162  ·  view source on GitHub ↗

Returns all declared parameters in the order they should be processed. The declared parameters are re-shuffled depending on the order in which they were invoked, as well as the eagerness of each parameters. The invocation order takes precedence over the declaration order. I.e. the

(
    invocation_order: cabc.Sequence[Parameter],
    declaration_order: cabc.Sequence[Parameter],
)

Source from the content-addressed store, hash-verified

136
137
138def iter_params_for_processing(
139 invocation_order: cabc.Sequence[Parameter],
140 declaration_order: cabc.Sequence[Parameter],
141) -> list[Parameter]:
142 """Returns all declared parameters in the order they should be processed.
143
144 The declared parameters are re-shuffled depending on the order in which
145 they were invoked, as well as the eagerness of each parameters.
146
147 The invocation order takes precedence over the declaration order. I.e. the
148 order in which the user provided them to the CLI is respected.
149
150 This behavior and its effect on callback evaluation is detailed at:
151 https://click.palletsprojects.com/en/stable/advanced/#callback-evaluation-order
152 """
153
154 def sort_key(item: Parameter) -> tuple[bool, float]:
155 try:
156 idx: float = invocation_order.index(item)
157 except ValueError:
158 idx = float("inf")
159
160 return not item.is_eager, idx
161
162 return sorted(declaration_order, key=sort_key)
163
164
165class ParameterSource(enum.IntEnum):

Callers 1

parse_argsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected