Skip to content
Snippets Groups Projects
Commit 313ec872 authored by Moul's avatar Moul
Browse files

[mypy] #163: Add type annotation on checksum, cli, and cli_tools

parent 51bcc060
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@ MESSAGE = "You should specify a pubkey or an authentication method"
Can also check if the checksum is valid",
)
@click.argument("pubkey_checksum", nargs=-1)
def checksum_command(pubkey_checksum):
def checksum_command(pubkey_checksum: str) -> None:
if has_auth_method():
key = auth_method()
click.echo(gen_pubkey_checksum(key.pubkey))
......
......@@ -15,7 +15,7 @@
import sys
from click import group, help_option, option, pass_context, version_option
from click import Context, group, help_option, option, pass_context, version_option
from duniterpy.api.endpoint import endpoint
from silkaj import revocation
......@@ -91,18 +91,18 @@ Do not send the document, but display it instead",
)
@pass_context
def cli(
ctx,
endpoint,
gtest,
auth_scrypt,
nrp,
auth_file,
file,
auth_seed,
auth_wif,
display,
dry_run,
):
ctx: Context,
endpoint: str,
gtest: bool,
auth_scrypt: bool,
nrp: str,
auth_file: bool,
file: str,
auth_seed: bool,
auth_wif: bool,
display: bool,
dry_run: bool,
) -> None:
if display and dry_run:
sys.exit("ERROR: display and dry-run options can not be used together")
......@@ -143,7 +143,7 @@ cli.add_command(received_sent_certifications)
Subcommands optionally take the path to the revocation document.",
)
@help_option("-h", "--help")
def revocation_group():
def revocation_group() -> None:
pass
......@@ -154,7 +154,7 @@ revocation_group.add_command(revocation.revoke_now)
@cli.command("about", help="Display program information")
def about():
def about() -> None:
print(
"\
\n @@@@@@@@@@@@@\
......
......@@ -13,11 +13,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
from click import Option, UsageError
from typing import Any
from click import Context, Option, UsageError
class MutuallyExclusiveOption(Option):
def __init__(self, *args, **kwargs):
def __init__(self, *args: Any, **kwargs: Any) -> None:
self.mutually_exclusive = set(kwargs.pop("mutually_exclusive", []))
help = kwargs.get("help", "")
if self.mutually_exclusive:
......@@ -27,7 +29,7 @@ class MutuallyExclusiveOption(Option):
] = f"{help} NOTE: This argument is mutually exclusive with arguments: [{ex_str}]."
super().__init__(*args, **kwargs)
def handle_parse_result(self, ctx, opts, args):
def handle_parse_result(self, ctx: Context, opts: Any, args: Any) -> Any:
if self.mutually_exclusive.intersection(opts) and self.name in opts:
arguments = ", ".join(self.mutually_exclusive)
raise UsageError(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment