Skip to content

Commit 854645f

Browse files
committed
Cleanup code following type refining
1 parent 5bd448d commit 854645f

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

src/click/core.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,7 +2762,7 @@ def __init__(
27622762
)
27632763

27642764
if prompt is True:
2765-
if self.name is None:
2765+
if not self.name:
27662766
raise TypeError("'name' is required with 'prompt=True'.")
27672767

27682768
prompt_text: str | None = self.name.replace("_", " ").capitalize()
@@ -3098,7 +3098,7 @@ def get_help_extra(self, ctx: Context) -> types.OptionHelpExtra:
30983098
if (
30993099
self.allow_from_autoenv
31003100
and ctx.auto_envvar_prefix is not None
3101-
and self.name is not None
3101+
and self.name
31023102
):
31033103
envvar = f"{ctx.auto_envvar_prefix}_{self.name.upper()}"
31043104

@@ -3237,11 +3237,7 @@ def resolve_envvar_value(self, ctx: Context) -> str | None:
32373237
if rv is not None:
32383238
return rv
32393239

3240-
if (
3241-
self.allow_from_autoenv
3242-
and ctx.auto_envvar_prefix is not None
3243-
and self.name is not None
3244-
):
3240+
if self.allow_from_autoenv and ctx.auto_envvar_prefix is not None and self.name:
32453241
envvar = f"{ctx.auto_envvar_prefix}_{self.name.upper()}"
32463242
rv = os.environ.get(envvar)
32473243

src/click/shell_completion.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,6 @@ def _is_incomplete_argument(ctx: Context, param: Parameter) -> bool:
511511
if not isinstance(param, Argument):
512512
return False
513513

514-
assert param.name is not None
515-
# Will be None if expose_value is False.
516514
value = ctx.params.get(param.name)
517515
return (
518516
param.nargs == -1

0 commit comments

Comments
 (0)