Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ black:
black setup.py samcli tests schema

black-check:
black --check setup.py samcli tests schema
@if python -c "import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)" 2>/dev/null; then \
black --check setup.py samcli tests schema; \
else \
echo "Skipping black check on Python < 3.10"; \
fi

format: black
ruff check samcli --fix
Expand Down
4 changes: 2 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ filelock==3.24.3; python_version>="3.10"
filelock==3.19.1; python_version<"3.10"

# formatter
black==25.9.0; python_version>="3.9"
black==24.8.0; python_version<"3.9"
black==26.1.0; python_version>"3.9"
black==25.9.0; python_version<="3.9"
psutil==7.2.1

# Pin chardet to avoid requests compatibility assertion failure (requests requires chardet < 6)
Expand Down
2 changes: 1 addition & 1 deletion samcli/cli/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _get_value(
)
return default

return value # type:ignore
return value # type: ignore

def set_value(self, config_entry: ConfigEntry, value: Any, is_flag: bool = False, flush: bool = True) -> None:
"""Set the value of a configuration. The associated env var will be updated as well.
Expand Down
2 changes: 1 addition & 1 deletion samcli/cli/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def convert(self, value, param, ctx):
)

for function_name, param_value in signing_profiles:
(signer_profile_name, signer_profile_owner) = self._split_signer_profile_name_owner(
signer_profile_name, signer_profile_owner = self._split_signer_profile_name_owner(
_unquote_wrapped_quotes(param_value)
)

Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/build/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def format_examples(ctx: Context, formatter: BuildCommandHelpTextFormatter):
],
)

def format_options(self, ctx: Context, formatter: BuildCommandHelpTextFormatter) -> None: # type:ignore
def format_options(self, ctx: Context, formatter: BuildCommandHelpTextFormatter) -> None: # type: ignore
# NOTE(sriram-mv): `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/deploy/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def format_acronyms(formatter: DeployCommandHelpTextFormatter):
col_max=COL_SIZE_MODIFIER,
)

def format_options(self, ctx: Context, formatter: DeployCommandHelpTextFormatter) -> None: # type:ignore
def format_options(self, ctx: Context, formatter: DeployCommandHelpTextFormatter) -> None: # type: ignore
# `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
Expand Down
6 changes: 3 additions & 3 deletions samcli/commands/deploy/guided_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def prompt_code_signing_settings(self, stacks: List[Stack]):
stacks : List[Stack]
List of stacks to search functions and layers
"""
(functions_with_code_sign, layers_with_code_sign) = signer_config_per_function(stacks)
functions_with_code_sign, layers_with_code_sign = signer_config_per_function(stacks)

# if no function or layer definition found with code signing, skip it
if not functions_with_code_sign and not layers_with_code_sign:
Expand All @@ -260,7 +260,7 @@ def prompt_code_signing_settings(self, stacks: List[Stack]):
click.echo("\t#Please provide signing profile details for the following functions & layers")

for function_name in functions_with_code_sign:
(profile_name, profile_owner) = extract_profile_name_and_owner_from_existing(
profile_name, profile_owner = extract_profile_name_and_owner_from_existing(
function_name, self.signing_profiles
)

Expand All @@ -271,7 +271,7 @@ def prompt_code_signing_settings(self, stacks: List[Stack]):
self.signing_profiles[function_name]["profile_owner"] = "" if not profile_owner else profile_owner

for layer_name, functions_use_this_layer in layers_with_code_sign.items():
(profile_name, profile_owner) = extract_profile_name_and_owner_from_existing(
profile_name, profile_owner = extract_profile_name_and_owner_from_existing(
layer_name, self.signing_profiles
)
click.echo(
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/docs/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def format_sub_commands(self, formatter: DocsCommandHelpTextFormatter):
col_max=50,
)

def format_options(self, ctx: Context, formatter: DocsCommandHelpTextFormatter): # type:ignore
def format_options(self, ctx: Context, formatter: DocsCommandHelpTextFormatter): # type: ignore
"""
Overrides the format_options method from the parent class to update
the help text formatting in a consistent method for the AWS SAM CLI
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/init/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def format_examples(ctx: Context, formatter: InitCommandHelpTextFormatter):
],
)

def format_options(self, ctx: Context, formatter: InitCommandHelpTextFormatter) -> None: # type:ignore
def format_options(self, ctx: Context, formatter: InitCommandHelpTextFormatter) -> None: # type: ignore
# `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/init/interactive_init_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,7 @@ def _generate_from_location(
-----------------------
Location: {location}
Output Directory: {output_dir}
""".format(
location=location, output_dir=output_dir
)
""".format(location=location, output_dir=output_dir)
click.echo(summary_msg)
do_generate(
location,
Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/local/callback/fail/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class LocalCallbackFailCommand(LocalCallbackCommand):
Command class for local callback fail command.
"""

def format_options(
self, ctx: Context, formatter: CommandHelpTextFormatter # type:ignore
) -> None:
def format_options(self, ctx: Context, formatter: CommandHelpTextFormatter) -> None: # type: ignore
self.format_description(formatter)
self.format_examples(ctx, formatter)

Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/local/callback/heartbeat/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class LocalCallbackHeartbeatCommand(LocalCallbackCommand):
Command class for local callback heartbeat command.
"""

def format_options(
self, ctx: Context, formatter: CommandHelpTextFormatter # type:ignore
) -> None:
def format_options(self, ctx: Context, formatter: CommandHelpTextFormatter) -> None: # type: ignore
self.format_description(formatter)
self.format_examples(ctx, formatter)

Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/local/callback/succeed/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class LocalCallbackSucceedCommand(LocalCallbackCommand):
Command class for local callback succeed command.
"""

def format_options(
self, ctx: Context, formatter: CommandHelpTextFormatter # type:ignore
) -> None:
def format_options(self, ctx: Context, formatter: CommandHelpTextFormatter) -> None: # type: ignore
self.format_description(formatter)
self.format_examples(ctx, formatter)

Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/local/execution/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def format_examples(self, ctx: Context, formatter: CommandHelpTextFormatter):
"""Override this method in subclasses to provide command-specific examples."""
pass

def format_options(
self, ctx: Context, formatter: CommandHelpTextFormatter # type:ignore
) -> None:
def format_options(self, ctx: Context, formatter: CommandHelpTextFormatter) -> None: # type: ignore
self.format_description(formatter)
self.format_examples(ctx, formatter)

Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/local/generate_event/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def format_examples(ctx: Context, formatter: RootCommandHelpTextFormatter):
]
)

def format_commands(self, ctx: Context, formatter: RootCommandHelpTextFormatter) -> None: # type:ignore
def format_commands(self, ctx: Context, formatter: RootCommandHelpTextFormatter) -> None: # type: ignore
# NOTE(sriram-mv): `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/local/invoke/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def format_examples(ctx: Context, formatter: InvokeCommandHelpTextFormatter):
]
)

def format_options(self, ctx: Context, formatter: InvokeCommandHelpTextFormatter) -> None: # type:ignore
def format_options(self, ctx: Context, formatter: InvokeCommandHelpTextFormatter) -> None: # type: ignore
# NOTE(sriram-mv): `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/local/start_api/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def format_examples(ctx: Context, formatter: InvokeStartAPICommandHelpTextFormat
]
)

def format_options(self, ctx: Context, formatter: InvokeStartAPICommandHelpTextFormatter) -> None: # type:ignore
def format_options(self, ctx: Context, formatter: InvokeStartAPICommandHelpTextFormatter) -> None: # type: ignore
# NOTE(sriram-mv): `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/local/start_lambda/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def format_examples(ctx: Context, formatter: InvokeStartLambdaCommandHelpTextFor
]
)

def format_options(self, ctx: Context, formatter: InvokeStartLambdaCommandHelpTextFormatter) -> None: # type:ignore
def format_options(self, ctx: Context, formatter: InvokeStartLambdaCommandHelpTextFormatter) -> None: # type: ignore
# NOTE(sriram-mv): `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/logs/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def format_examples(ctx: Context, formatter: LogsCommandHelpTextFormatter):
]
)

def format_options(self, ctx: Context, formatter: LogsCommandHelpTextFormatter) -> None: # type:ignore
def format_options(self, ctx: Context, formatter: LogsCommandHelpTextFormatter) -> None: # type: ignore
# `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/package/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def format_acronyms(formatter: PackageCommandHelpTextFormatter):
col_max=COL_SIZE_MODIFIER,
)

def format_options(self, ctx: Context, formatter: PackageCommandHelpTextFormatter) -> None: # type:ignore
def format_options(self, ctx: Context, formatter: PackageCommandHelpTextFormatter) -> None: # type: ignore
# `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
Expand Down
22 changes: 6 additions & 16 deletions samcli/commands/pipeline/bootstrap/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,15 @@ def do_cli(
if interactive:
if standalone:
click.echo(
dedent(
"""\
dedent("""\

sam pipeline bootstrap generates the required AWS infrastructure resources to connect
to your CI/CD system. This step must be run for each deployment stage in your pipeline,
prior to running the sam pipeline init command.

We will ask for [1] stage definition, [2] account details, and
[3] references to existing resources in order to bootstrap these pipeline resources.
"""
),
"""),
)

guided_context = GuidedContext(
Expand Down Expand Up @@ -413,26 +411,18 @@ def do_cli(
config_dir=PIPELINE_CONFIG_DIR, filename=PIPELINE_CONFIG_FILENAME, cmd_names=_get_bootstrap_command_names()
)

click.secho(
dedent(
f"""\
click.secho(dedent(f"""\
View the definition in {os.path.join(PIPELINE_CONFIG_DIR, PIPELINE_CONFIG_FILENAME)},
run sam pipeline bootstrap to generate another set of resources, or proceed to
sam pipeline init to create your pipeline configuration file.
"""
)
)
"""))

if not environment.pipeline_user.is_user_provided and not environment.use_oidc_provider:
click.secho(
dedent(
f"""\
click.secho(dedent(f"""\
Before running {Colored().bold("sam pipeline init")}, we recommend first setting up AWS credentials
in your CI/CD account. Read more about how to do so with your provider in
{CONFIG_AWS_CRED_ON_CICD_URL}.
"""
)
)
"""))


def _get_pipeline_oidc_provider(
Expand Down
8 changes: 2 additions & 6 deletions samcli/commands/pipeline/bootstrap/guided_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,10 @@ def __init__(
def _prompt_account_id(self) -> None:
profiles = list_available_profiles()
click.echo("The following AWS credential sources are available to use.")
click.echo(
dedent(
f"""\
click.echo(dedent(f"""\
To know more about configuration AWS credentials, visit the link below:
{CONFIG_AWS_CRED_DOC_URL}\
"""
)
)
"""))
has_env_creds = os.getenv(EnvProvider.ACCESS_KEY) and os.getenv(EnvProvider.SECRET_KEY)
click.echo(f"\t1 - Environment variables{' (not available)' if not has_env_creds else ''}")
for i, profile in enumerate(profiles):
Expand Down
24 changes: 6 additions & 18 deletions samcli/commands/pipeline/init/interactive_init_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,15 @@ def do_interactive(self) -> None:
runs its specific questionnaire then generates the pipeline config file
based on the template and user's responses
"""
click.echo(
dedent(
"""\
click.echo(dedent("""\

sam pipeline init generates a pipeline configuration file that your CI/CD system
can use to deploy serverless applications using AWS SAM.
We will guide you through the process to bootstrap resources for each stage,
then walk through the details necessary for creating the pipeline config file.

Please ensure you are in the root folder of your SAM application before you begin.
"""
)
)
"""))

pipeline_template_source_question = Choice(
key="pipeline-template-source",
Expand Down Expand Up @@ -173,9 +169,7 @@ def _prompt_run_bootstrap_within_pipeline_init(
"you can still reference other bootstrapped resources.",
default=True,
):
click.secho(
dedent(
"""\
click.secho(dedent("""\

For each stage, we will ask for [1] stage definition, [2] account details, and [3]
reference application build resources in order to bootstrap these pipeline
Expand All @@ -184,9 +178,7 @@ def _prompt_run_bootstrap_within_pipeline_init(
We recommend using an individual AWS account profiles for each stage in your
pipeline. You can set these profiles up using aws configure or ~/.aws/credentials. See
[https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-set-up-credentials.html].
""" # pylint: disable=C0301
)
)
""")) # pylint: disable=C0301

click.echo(Colored().bold(f"\nStage {len(stage_configuration_names) + 1} Setup\n"))
do_bootstrap(
Expand Down Expand Up @@ -218,15 +210,11 @@ def _prompt_run_bootstrap_within_pipeline_init(
)
return True
else:
click.echo(
dedent(
"""\
click.echo(dedent("""\
To set up stage(s), please quit the process using Ctrl+C and use one of the following commands:
sam pipeline init --bootstrap To be guided through the stage and config file creation process.
sam pipeline bootstrap To specify details for an individual stage.
"""
)
)
"""))
click.prompt(
"To reference stage resources bootstrapped in a different account, press enter to proceed", default=""
)
Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/publish/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
--------
To publish an application
$ sam publish -t packaged.yaml --region <region>
""".format(
SAM_PUBLISH_DOC
)
""".format(SAM_PUBLISH_DOC)
SHORT_HELP = "Publish a packaged AWS SAM template to the AWS Serverless Application Repository."
SERVERLESSREPO_CONSOLE_URL = "https://console.aws.amazon.com/serverlessrepo/home?region={}#/published-applications/{}"
SEMANTIC_VERSION_HELP = "Optional. The value provided here overrides SemanticVersion in the template metadata."
Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/remote/callback/fail/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class RemoteCallbackFailCommand(RemoteCommand):
Command class for remote callback fail command.
"""

def format_options(
self, ctx: Context, formatter: CommandHelpTextFormatter # type:ignore
) -> None:
def format_options(self, ctx: Context, formatter: CommandHelpTextFormatter) -> None: # type: ignore
self.format_description(formatter)
self.format_examples(ctx, formatter)

Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/remote/callback/heartbeat/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class RemoteCallbackHeartbeatCommand(RemoteCommand):
Command class for remote callback heartbeat command.
"""

def format_options(
self, ctx: Context, formatter: CommandHelpTextFormatter # type:ignore
) -> None:
def format_options(self, ctx: Context, formatter: CommandHelpTextFormatter) -> None: # type: ignore
self.format_description(formatter)
self.format_examples(ctx, formatter)

Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/remote/callback/succeed/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class RemoteCallbackSucceedCommand(RemoteCommand):
Command class for remote callback succeed command.
"""

def format_options(
self, ctx: Context, formatter: CommandHelpTextFormatter # type:ignore
) -> None:
def format_options(self, ctx: Context, formatter: CommandHelpTextFormatter) -> None: # type: ignore
self.format_description(formatter)
self.format_examples(ctx, formatter)

Expand Down
4 changes: 1 addition & 3 deletions samcli/commands/remote/execution/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def format_execution_arn_note(formatter: CommandHelpTextFormatter):
]
)

def format_options(
self, ctx: Context, formatter: CommandHelpTextFormatter # type:ignore
) -> None:
def format_options(self, ctx: Context, formatter: CommandHelpTextFormatter) -> None: # type: ignore
self.format_description(formatter)
self.format_examples(ctx, formatter)
self.format_execution_arn_note(formatter)
Expand Down
Loading
Loading