Skip to content

Commit da7774b

Browse files
committed
Cleanup code following type refining
1 parent b02fdf9 commit da7774b

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
@@ -2773,7 +2773,7 @@ def __init__(
27732773
)
27742774

27752775
if prompt is True:
2776-
if self.name is None:
2776+
if not self.name:
27772777
raise TypeError("'name' is required with 'prompt=True'.")
27782778

27792779
prompt_text: str | None = self.name.replace("_", " ").capitalize()
@@ -3122,7 +3122,7 @@ def get_help_extra(self, ctx: Context) -> types.OptionHelpExtra:
31223122
if (
31233123
self.allow_from_autoenv
31243124
and ctx.auto_envvar_prefix is not None
3125-
and self.name is not None
3125+
and self.name
31263126
):
31273127
envvar = f"{ctx.auto_envvar_prefix}_{self.name.upper()}"
31283128

@@ -3261,11 +3261,7 @@ def resolve_envvar_value(self, ctx: Context) -> str | None:
32613261
if rv is not None:
32623262
return rv
32633263

3264-
if (
3265-
self.allow_from_autoenv
3266-
and ctx.auto_envvar_prefix is not None
3267-
and self.name is not None
3268-
):
3264+
if self.allow_from_autoenv and ctx.auto_envvar_prefix is not None and self.name:
32693265
envvar = f"{ctx.auto_envvar_prefix}_{self.name.upper()}"
32703266
rv = os.environ.get(envvar)
32713267

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)