88###########################################################################
99"""Reusable command line interface options for the setup commands."""
1010
11+ from __future__ import annotations
12+
1113import functools
1214import getpass
15+ import typing as t
1316
1417import click
1518
1619from aiida .brokers .rabbitmq .defaults import BROKER_DEFAULTS
1720from aiida .cmdline .params import options , types
1821from aiida .manage .configuration import Profile , get_config , get_config_option
19- from aiida .manage .external .postgres import DEFAULT_DBINFO
22+ from aiida .manage .external .postgres import DEFAULT_DBINFO # type: ignore[attr-defined]
2023
2124PASSWORD_UNCHANGED = '***'
2225
2326
24- def validate_profile_parameter (ctx ) :
27+ def validate_profile_parameter (ctx : click . Context ) -> None :
2528 """Validate that the context contains the option `profile` and it contains a `Profile` instance.
2629
2730 :param ctx: click context which should contain the selected profile
@@ -32,10 +35,10 @@ def validate_profile_parameter(ctx):
3235 raise click .BadParameter ('specifying the name of the profile is required' , param_hint = f'"--{ option } "' )
3336
3437
35- def get_profile_attribute_default (attribute_tuple , ctx ) :
38+ def get_profile_attribute_default (attribute_tuple : tuple [ str , t . Any ], ctx : click . Context ) -> t . Any :
3639 """Return the default value for the given attribute of the profile passed in the context.
3740
38- :param attribute : attribute for which to get the current value
41+ :param attribute_tuple : attribute for which to get the current value, and its default
3942 :param ctx: click context which should contain the selected profile
4043 :return: profile attribute default value if set, or None
4144 """
@@ -58,7 +61,7 @@ def get_profile_attribute_default(attribute_tuple, ctx):
5861 return default
5962
6063
61- def get_repository_uri_default (ctx ) :
64+ def get_repository_uri_default (ctx : click . Context ) -> str :
6265 """Return the default value for the repository URI for the current profile in the click context.
6366
6467 :param ctx: click context which should contain the selected profile
@@ -74,7 +77,7 @@ def get_repository_uri_default(ctx):
7477 return os .path .join (configure_directory , 'repository' , ctx .params ['profile' ].name )
7578
7679
77- def get_quicksetup_repository_uri (ctx , param , value ) :
80+ def get_quicksetup_repository_uri (ctx : click . Context , _param : click . Parameter , _value : t . Any ) -> str :
7881 """Return the repository URI to be used as default in `verdi quicksetup`
7982
8083 :param ctx: click context which should contain the contextual parameters
@@ -83,7 +86,7 @@ def get_quicksetup_repository_uri(ctx, param, value):
8386 return get_repository_uri_default (ctx )
8487
8588
86- def get_quicksetup_database_name (ctx , param , value ) :
89+ def get_quicksetup_database_name (ctx : click . Context , _param : click . Parameter , value : str | None ) -> str :
8790 """Determine the database name to be used as default for the Postgres connection in `verdi quicksetup`
8891
8992 If a value is explicitly passed, that value is returned unchanged.
@@ -109,7 +112,7 @@ def get_quicksetup_database_name(ctx, param, value):
109112 return database_name
110113
111114
112- def get_quicksetup_username (ctx , param , value ) :
115+ def get_quicksetup_username (ctx : click . Context , param : click . Parameter , value : str | None ) -> str :
113116 """Determine the username to be used as default for the Postgres connection in `verdi quicksetup`
114117
115118 If a value is explicitly passed, that value is returned. If there is no value, the name will be based on the
@@ -130,7 +133,7 @@ def get_quicksetup_username(ctx, param, value):
130133 return username
131134
132135
133- def get_quicksetup_password (ctx , param , value ) :
136+ def get_quicksetup_password (ctx : click . Context , param : click . Parameter , value : str | None ) -> str :
134137 """Determine the password to be used as default for the Postgres connection in `verdi quicksetup`
135138
136139 If a value is explicitly passed, that value is returned. If there is no value, the current username in the context
0 commit comments