Skip to content
Myr

Update comments on UNSET handling during parse_args

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Per review feedback: - Remove an extraneous comment - Expand another, more significant comment

authored by Stephen Rosen · committed by Stephen Rosen · parent 1c20dc6 · Browse files · 1 file+9 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Kevin Deldycke <159718+kdeldycke@users.noreply.github.com>

Diff stats

1 file+9 added−5 removed

  • other:+9 added−5 removed

1 file+9 added−5 removed

modified:src/click/core.py+9 added-5 removed
1224 unmodified lines
12251226 for param in iter_params_for_processing(param_order, self.get_params(ctx)):1227 _, args = param.handle_parse_result(ctx, opts, args)12281229 # after handling *all* parameters, do a pass over the params to rewrite1230 # `UNSET`1229 # We now have all parameters' values into `ctx.params`, but the data may contain1230 # the `UNSET` sentinel.1231 # Convert `UNSET` to `None` to ensure that the user doesn't see `UNSET`.1232 #1233 # Waiting until after the initial parse to convert allows us to treat `UNSET`1234 # more like a missing value when multiple params use the same name.1235 # Refs:1236 # https://github.com/pallets/click/issues/30711237 # https://github.com/pallets/click/pull/30791238 for name, value in ctx.params.items():1239 if value is UNSET:1240 ctx.params[name] = None1241
1315 unmodified lines
2557 # not to be exposed. We still assert it here to please the type checker.2558 assert self.name is not None, (2559 f"{self!r} parameter's name should not be None when exposing value."2560 )2554 # Do not normalize UNSET values to None at this point2555 # It needs to be done, but doing so too early impacts multiple parameters2556 # targeting the same variable name2561 ctx.params[self.name] = value25622563 return value, args2564
803 unmodified lines