Skip to content

Commit

Permalink
Tests for password_option
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Jul 9, 2023
1 parent 6adeb58 commit ad1ad34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/click/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
from functools import update_wrapper
from gettext import gettext as _

from .core import Argument
from .core import Command
from .core import Context
from .core import Group
from .core import Option
from .core import Parameter
from .core import Argument, Command, Context, Group, Option, Parameter
from .globals import get_current_context
from .utils import echo

Expand Down Expand Up @@ -405,7 +400,7 @@ def callback(ctx: Context, param: Parameter, value: bool) -> None:
return option(*param_decls, **kwargs)


def password_option(*param_decls: str, **kwargs: t.Any) -> _Decorator[FC]:
def password_option(*param_decls: str, **kwargs: t.Any) -> t.Callable[[FC], FC]:
"""Add a ``--password`` option which prompts for a password, hiding
input and asking to enter the value again for confirmation.
Expand Down
14 changes: 14 additions & 0 deletions tests/typing/typing_password_option.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import codecs

from typing_extensions import assert_type

import click


@click.command()
@click.password_option()
def encrypt(password: str) -> None:
click.echo(f"encoded: to {codecs.encode(password, 'rot13')}")


assert_type(encrypt, click.Command)

0 comments on commit ad1ad34

Please sign in to comment.