Don't refactor variable names unnecessarily
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kevin Deldycke · committed by Kevin Deldycke · parent c442c05 · Browse files · 1 file·+19 added−19 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Address: https://github.com/pallets/click/pull/3030/files#r2289177206
Diff stats
1 file+19 added−19 removed
- other:+19 added−19 removed
Provenance
- Commit
634549f- Tree
3030deb- Author
Kevin Deldycke <kevin@deldycke.com>- Committer
Kevin Deldycke <kevin@deldycke.com>- Parent
c442c05
1 file changed+19 added−19 removed
modified:src/click/core.py+19 added-19 removed
2405 unmodified lines2406 return None2407 2408 envvars = [self.envvar] if isinstance(self.envvar, str) else self.envvar2409 for envvar in envvars:2410- raw_value = os.environ.get(envvar)2410+ rv = os.environ.get(envvar)2411 2412 # Return the first non-empty value of the list of environment variables.2413- if raw_value:2414- return raw_value2413+ if rv:2414+ return rv2415 # Else, absence of value is interpreted as an environment variable that is2416 # not set, so proceed to the next one.2417 2418 return None4 unmodified lines2423 Returns the string as-is or splits it into a sequence of strings if the2424 parameter is expecting multiple values (i.e. its :attr:`nargs` property is set2425 to a value other than ``1``).2426 """2427- raw_value = self.resolve_envvar_value(ctx)2427+ rv = self.resolve_envvar_value(ctx)2428 2429- if raw_value is not None and self.nargs != 1:2430- return self.type.split_envvar_value(raw_value)2429+ if rv is not None and self.nargs != 1:2430+ return self.type.split_envvar_value(rv)2431 2432- return raw_value2432+ return rv2433 2434 def handle_parse_result(2435 self, ctx: Context, opts: cabc.Mapping[str, t.Any], args: list[str]2436 ) -> tuple[t.Any, list[str]]:598 unmodified lines3035 the :attr:`envvar` property, we fallback on :attr:`Context.auto_envvar_prefix`3036 to build dynamiccaly the environment variable name using the3037 :python:`{ctx.auto_envvar_prefix}_{self.name.upper()}` template.3038 """3039- raw_value = super().resolve_envvar_value(ctx)3039+ rv = super().resolve_envvar_value(ctx)3040 3041- if raw_value is not None:3042- return raw_value3041+ if rv is not None:3042+ return rv3043 3044 if (3045 self.allow_from_autoenv3046 and ctx.auto_envvar_prefix is not None3047 and self.name is not None3048 ):3049 envvar = f"{ctx.auto_envvar_prefix}_{self.name.upper()}"3050- raw_value = os.environ.get(envvar)3050+ rv = os.environ.get(envvar)3051 3052 # Return the first non-empty value of the list of environment variables.3053- if raw_value:3054- return raw_value3053+ if rv:3054+ return rv3055 # Else, absence of value is interpreted as an environment variable that is3056 # not set, so proceed to the next one.3057 3058 return None9 unmodified lines3068 3069 This method also takes care of repeated options (i.e. options with3070 :attr:`multiple` set to ``True``).3071 """3072- raw_value = self.resolve_envvar_value(ctx)3072+ rv = self.resolve_envvar_value(ctx)3073 3074 # Absent environment variable or an empty string is interpreted as unset.3075- if raw_value is None:3075+ if rv is None:3076 return None3077 3078 # Non-boolean flags are more liberal in what they accept. But a flag being a3079 # flag, its envvar value still needs to be analyzed to determine if the flag is3080 # activated or not.3081 if self.is_flag and not self.is_bool_flag:3082 # If the flag_value is set and match the envvar value, return it3083 # directly.3084- if self.flag_value is not UNSET and raw_value == self.flag_value:3084+ if self.flag_value is not UNSET and rv == self.flag_value:3085 return self.flag_value3086 # Analyze the envvar value as a boolean to know if the flag is3087 # activated or not.3088- return types.BoolParamType.str_to_bool(raw_value)3088+ return types.BoolParamType.str_to_bool(rv)3089 3090 # Split the envvar value if it is allowed to be repeated.3091 value_depth = (self.nargs != 1) + bool(self.multiple)3092 if value_depth > 0:3093- multi_rv = self.type.split_envvar_value(raw_value)3093+ multi_rv = self.type.split_envvar_value(rv)3094 if self.multiple and self.nargs != 1:3095 multi_rv = batch(multi_rv, self.nargs) # type: ignore[assignment]3096 3097 return multi_rv3098 3099- return raw_value3099+ return rv3100 3101 def consume_value(3102 self, ctx: Context, opts: cabc.Mapping[str, Parameter]3103 ) -> tuple[t.Any, ParameterSource]:169 unmodified lines