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],
)
| 136 | |
| 137 | |
| 138 | def 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 | |
| 165 | class ParameterSource(enum.IntEnum): |