diff --git a/requirements/base.txt b/requirements/base.txt index 0c03e917c7..8ff9bdc57d 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -6,7 +6,7 @@ jmespath~=1.0.1 ruamel_yaml~=0.18.5 PyYAML~=6.0,>=6.0.1 cookiecutter~=2.5.0 -aws-sam-translator==1.83.0 +aws-sam-translator==1.84.0 #docker minor version updates can include breaking changes. Auto update micro version only. docker~=7.0.0 dateparser~=1.2 diff --git a/requirements/dev.txt b/requirements/dev.txt index 7b92363b67..05585cb879 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -11,10 +11,10 @@ mypy==1.8.0 types-pywin32==306.0.0.20240130 types-PyYAML==6.0.12.12 types-chevron==0.14.2.20240106 -types-psutil==5.9.5.20240106 +types-psutil==5.9.5.20240205 types-setuptools==69.0.0.20240125 types-Pygments==2.17.0.20240106 -types-colorama==0.4.15.20240106 +types-colorama==0.4.15.20240205 types-dateparser==1.1.4.20240106 types-docutils==0.20.0.20240201 types-jsonschema==4.21.0.20240118 @@ -36,5 +36,5 @@ pytest-json-report==1.5.0 filelock==3.13.1 # formatter -black==23.12.1 +black==24.1.1 psutil==5.9.8 diff --git a/requirements/pre-dev.txt b/requirements/pre-dev.txt index 43172de738..2446b4802f 100644 --- a/requirements/pre-dev.txt +++ b/requirements/pre-dev.txt @@ -1 +1 @@ -ruff==0.1.15 +ruff==0.2.0 diff --git a/requirements/reproducible-linux.txt b/requirements/reproducible-linux.txt index 5c6eaae465..b9416facb5 100644 --- a/requirements/reproducible-linux.txt +++ b/requirements/reproducible-linux.txt @@ -24,9 +24,9 @@ aws-lambda-builders==1.45.0 \ --hash=sha256:5c19a6628eecf21578cd9c521e747f4a2163c62c527cd840b11b62a10b661348 \ --hash=sha256:a4db7766198c052900905bd7ee3b1a8b486511394cdabffed054204d43b29943 # via aws-sam-cli (setup.py) -aws-sam-translator==1.83.0 \ - --hash=sha256:022246b4745cc9067f88ab2b051f49898606bcf0222e22b9da41063e5619c6f9 \ - --hash=sha256:46025ca8894a56eacd87eb0e4f9af5c01c567c9a734b97fbba353bffd56ba5dc +aws-sam-translator==1.84.0 \ + --hash=sha256:a24f43e80095c79258a1f1c7a0b8169f55daf0b2bc237d5b9010b02ba86fa3bb \ + --hash=sha256:dbfd5669b5ef4bd7bc7af4775eec2ce4db61a2c2a17d721e67b51cf6a6dd63f9 # via # aws-sam-cli (setup.py) # cfn-lint @@ -60,9 +60,9 @@ botocore-stubs==1.34.32 \ --hash=sha256:978c97b8c02b5ffa3726a5052e5715aecc52c640a75a8088b3a58453c2b054b2 \ --hash=sha256:e5b04b8ab81e736088470b7be244de072ac2f986caf0f51b7e2087400778dc9f # via boto3-stubs -certifi==2023.11.17 \ - --hash=sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1 \ - --hash=sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474 +certifi==2024.2.2 \ + --hash=sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f \ + --hash=sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1 # via requests cffi==1.16.0 \ --hash=sha256:0c9ef6ff37e974b73c25eecc13952c55bceed9112be2d9d938ded8e856138bcc \ @@ -585,9 +585,9 @@ python-slugify==8.0.3 \ --hash=sha256:c71189c161e8c671f1b141034d9a56308a8a5978cd13d40446c879569212fdd1 \ --hash=sha256:e04cba5f1c562502a1175c84a8bc23890c54cdaf23fccaaf0bf78511508cabed # via cookiecutter -pytz==2023.4 \ - --hash=sha256:31d4583c4ed539cd037956140d695e42c033a19e984bfce9964a3f7d59bc2b40 \ - --hash=sha256:f90ef520d95e7c46951105338d918664ebfd6f1d995bd7d153127ce90efafa6a +pytz==2024.1 \ + --hash=sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812 \ + --hash=sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319 # via dateparser pyyaml==6.0.1 \ --hash=sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc \ diff --git a/requirements/reproducible-mac.txt b/requirements/reproducible-mac.txt index 79f5480ecc..98078d0f88 100644 --- a/requirements/reproducible-mac.txt +++ b/requirements/reproducible-mac.txt @@ -24,9 +24,9 @@ aws-lambda-builders==1.45.0 \ --hash=sha256:5c19a6628eecf21578cd9c521e747f4a2163c62c527cd840b11b62a10b661348 \ --hash=sha256:a4db7766198c052900905bd7ee3b1a8b486511394cdabffed054204d43b29943 # via aws-sam-cli (setup.py) -aws-sam-translator==1.83.0 \ - --hash=sha256:022246b4745cc9067f88ab2b051f49898606bcf0222e22b9da41063e5619c6f9 \ - --hash=sha256:46025ca8894a56eacd87eb0e4f9af5c01c567c9a734b97fbba353bffd56ba5dc +aws-sam-translator==1.84.0 \ + --hash=sha256:a24f43e80095c79258a1f1c7a0b8169f55daf0b2bc237d5b9010b02ba86fa3bb \ + --hash=sha256:dbfd5669b5ef4bd7bc7af4775eec2ce4db61a2c2a17d721e67b51cf6a6dd63f9 # via # aws-sam-cli (setup.py) # cfn-lint @@ -78,9 +78,9 @@ botocore-stubs==1.34.32 \ --hash=sha256:978c97b8c02b5ffa3726a5052e5715aecc52c640a75a8088b3a58453c2b054b2 \ --hash=sha256:e5b04b8ab81e736088470b7be244de072ac2f986caf0f51b7e2087400778dc9f # via boto3-stubs -certifi==2023.11.17 \ - --hash=sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1 \ - --hash=sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474 +certifi==2024.2.2 \ + --hash=sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f \ + --hash=sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1 # via requests cffi==1.16.0 \ --hash=sha256:0c9ef6ff37e974b73c25eecc13952c55bceed9112be2d9d938ded8e856138bcc \ @@ -617,9 +617,9 @@ python-slugify==8.0.3 \ --hash=sha256:c71189c161e8c671f1b141034d9a56308a8a5978cd13d40446c879569212fdd1 \ --hash=sha256:e04cba5f1c562502a1175c84a8bc23890c54cdaf23fccaaf0bf78511508cabed # via cookiecutter -pytz==2023.4 \ - --hash=sha256:31d4583c4ed539cd037956140d695e42c033a19e984bfce9964a3f7d59bc2b40 \ - --hash=sha256:f90ef520d95e7c46951105338d918664ebfd6f1d995bd7d153127ce90efafa6a +pytz==2024.1 \ + --hash=sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812 \ + --hash=sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319 # via dateparser pyyaml==6.0.1 \ --hash=sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc \ diff --git a/requirements/reproducible-win.txt b/requirements/reproducible-win.txt index f60951b0e9..919e335d41 100644 --- a/requirements/reproducible-win.txt +++ b/requirements/reproducible-win.txt @@ -24,9 +24,9 @@ aws-lambda-builders==1.45.0 \ --hash=sha256:5c19a6628eecf21578cd9c521e747f4a2163c62c527cd840b11b62a10b661348 \ --hash=sha256:a4db7766198c052900905bd7ee3b1a8b486511394cdabffed054204d43b29943 # via aws-sam-cli (setup.py) -aws-sam-translator==1.83.0 \ - --hash=sha256:022246b4745cc9067f88ab2b051f49898606bcf0222e22b9da41063e5619c6f9 \ - --hash=sha256:46025ca8894a56eacd87eb0e4f9af5c01c567c9a734b97fbba353bffd56ba5dc +aws-sam-translator==1.84.0 \ + --hash=sha256:a24f43e80095c79258a1f1c7a0b8169f55daf0b2bc237d5b9010b02ba86fa3bb \ + --hash=sha256:dbfd5669b5ef4bd7bc7af4775eec2ce4db61a2c2a17d721e67b51cf6a6dd63f9 # via # aws-sam-cli (setup.py) # cfn-lint @@ -60,9 +60,9 @@ botocore-stubs==1.34.32 \ --hash=sha256:978c97b8c02b5ffa3726a5052e5715aecc52c640a75a8088b3a58453c2b054b2 \ --hash=sha256:e5b04b8ab81e736088470b7be244de072ac2f986caf0f51b7e2087400778dc9f # via boto3-stubs -certifi==2023.11.17 \ - --hash=sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1 \ - --hash=sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474 +certifi==2024.2.2 \ + --hash=sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f \ + --hash=sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1 # via requests cffi==1.16.0 \ --hash=sha256:0c9ef6ff37e974b73c25eecc13952c55bceed9112be2d9d938ded8e856138bcc \ @@ -589,9 +589,9 @@ python-slugify==8.0.3 \ --hash=sha256:c71189c161e8c671f1b141034d9a56308a8a5978cd13d40446c879569212fdd1 \ --hash=sha256:e04cba5f1c562502a1175c84a8bc23890c54cdaf23fccaaf0bf78511508cabed # via cookiecutter -pytz==2023.4 \ - --hash=sha256:31d4583c4ed539cd037956140d695e42c033a19e984bfce9964a3f7d59bc2b40 \ - --hash=sha256:f90ef520d95e7c46951105338d918664ebfd6f1d995bd7d153127ce90efafa6a +pytz==2024.1 \ + --hash=sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812 \ + --hash=sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319 # via dateparser pywin32==306 \ --hash=sha256:06d3420a5155ba65f0b72f2699b5bacf3109f36acbe8923765c22938a69dfc8d \ diff --git a/samcli/__init__.py b/samcli/__init__.py index 3fefdee986..513927b9d1 100644 --- a/samcli/__init__.py +++ b/samcli/__init__.py @@ -2,4 +2,4 @@ SAM CLI version """ -__version__ = "1.108.0" +__version__ = "1.109.0" diff --git a/samcli/cli/cli_config_file.py b/samcli/cli/cli_config_file.py index 5c26c93ee7..ee2a69e9d9 100644 --- a/samcli/cli/cli_config_file.py +++ b/samcli/cli/cli_config_file.py @@ -406,9 +406,9 @@ def hello(name): def decorator_configuration_setup(f): configuration_setup_params = () configuration_setup_attrs = {} - configuration_setup_attrs[ - "help" - ] = "This is a hidden click option whose callback function loads configuration parameters." + configuration_setup_attrs["help"] = ( + "This is a hidden click option whose callback function loads configuration parameters." + ) configuration_setup_attrs["is_eager"] = True configuration_setup_attrs["expose_value"] = False configuration_setup_attrs["hidden"] = True diff --git a/samcli/cli/command.py b/samcli/cli/command.py index df14266948..9a52bd08dc 100644 --- a/samcli/cli/command.py +++ b/samcli/cli/command.py @@ -1,6 +1,7 @@ """ Base classes that implement the CLI framework """ + import importlib import logging from collections import OrderedDict diff --git a/samcli/cli/core/command.py b/samcli/cli/core/command.py index 27f239b31a..7c45f71aa0 100644 --- a/samcli/cli/core/command.py +++ b/samcli/cli/core/command.py @@ -4,6 +4,7 @@ Should be used by all commands for a consistent UI experience """ + from typing import Any, Dict, List, Optional from click import Command, Context, Parameter, style diff --git a/samcli/cli/core/options.py b/samcli/cli/core/options.py index 8d9132c8cf..b1b56fcf05 100644 --- a/samcli/cli/core/options.py +++ b/samcli/cli/core/options.py @@ -1,6 +1,7 @@ """ Base Command Options related Data Structures for formatting. """ + from typing import Dict, List # The ordering of the option lists matter, they are the order in which options will be displayed. diff --git a/samcli/cli/formatters.py b/samcli/cli/formatters.py index c6045ea2b5..6a907cec36 100644 --- a/samcli/cli/formatters.py +++ b/samcli/cli/formatters.py @@ -1,6 +1,7 @@ """ Click Help Formatter Classes that are customized for the root command. """ + from contextlib import contextmanager from typing import Iterator, Optional, Sequence diff --git a/samcli/cli/global_config.py b/samcli/cli/global_config.py index 6b4b8c71b2..b4f587ce84 100644 --- a/samcli/cli/global_config.py +++ b/samcli/cli/global_config.py @@ -1,6 +1,7 @@ """ Provides global configuration helpers. """ + import json import logging import os @@ -154,8 +155,7 @@ def get_value( value_type: Type[bool], is_flag: bool, reload_config: bool = False, - ) -> bool: - ... + ) -> bool: ... # Overload for case where type is specified @overload @@ -166,8 +166,7 @@ def get_value( value_type: Type[T] = T, # type: ignore is_flag: bool = False, reload_config: bool = False, - ) -> Optional[T]: - ... + ) -> Optional[T]: ... # Overload for case where type is not specified and default to object @overload @@ -178,8 +177,7 @@ def get_value( value_type: object = object, is_flag: bool = False, reload_config: bool = False, - ) -> Any: - ... + ) -> Any: ... def get_value( self, diff --git a/samcli/cli/hidden_imports.py b/samcli/cli/hidden_imports.py index 99d21820a9..c6c30b071a 100644 --- a/samcli/cli/hidden_imports.py +++ b/samcli/cli/hidden_imports.py @@ -1,6 +1,7 @@ """ Keeps list of hidden/dynamic imports that is being used in SAM CLI, so that pyinstaller can include these packages """ + import pkgutil from types import ModuleType diff --git a/samcli/cli/root/command_list.py b/samcli/cli/root/command_list.py index cfa7000739..dc5316b5ca 100644 --- a/samcli/cli/root/command_list.py +++ b/samcli/cli/root/command_list.py @@ -1,6 +1,7 @@ """ Data structure to host the root command name and short help text to speed up load time. """ + SAM_CLI_COMMANDS = { "init": "Initialize an AWS SAM application.", "validate": "Validate an AWS SAM template.", diff --git a/samcli/commands/_utils/cdk_support_decorators.py b/samcli/commands/_utils/cdk_support_decorators.py index 4e9ccbb39b..ddfdc8b487 100644 --- a/samcli/commands/_utils/cdk_support_decorators.py +++ b/samcli/commands/_utils/cdk_support_decorators.py @@ -1,4 +1,5 @@ """CDK Support""" + import logging import click diff --git a/samcli/commands/_utils/click_mutex.py b/samcli/commands/_utils/click_mutex.py index 397e43acba..1691bd2ce6 100644 --- a/samcli/commands/_utils/click_mutex.py +++ b/samcli/commands/_utils/click_mutex.py @@ -1,6 +1,7 @@ """ Module to check mutually exclusive cli parameters """ + from typing import Any, List, Mapping, Tuple, cast import click diff --git a/samcli/commands/_utils/command_exception_handler.py b/samcli/commands/_utils/command_exception_handler.py index e9dc5a862a..e84bdf41cc 100644 --- a/samcli/commands/_utils/command_exception_handler.py +++ b/samcli/commands/_utils/command_exception_handler.py @@ -2,6 +2,7 @@ Contains method decorator which can be used to convert common exceptions into click exceptions which will end execution gracefully """ + from functools import wraps from typing import Any, Callable, Dict, Optional diff --git a/samcli/commands/_utils/constants.py b/samcli/commands/_utils/constants.py index 7f0f8bb0e3..e411142ad7 100644 --- a/samcli/commands/_utils/constants.py +++ b/samcli/commands/_utils/constants.py @@ -1,6 +1,7 @@ """ SAM CLI Default Build constants """ + import os DEFAULT_STACK_NAME = "sam-app" diff --git a/samcli/commands/_utils/custom_options/replace_help_option.py b/samcli/commands/_utils/custom_options/replace_help_option.py index ff538c7a25..cfce8eee60 100644 --- a/samcli/commands/_utils/custom_options/replace_help_option.py +++ b/samcli/commands/_utils/custom_options/replace_help_option.py @@ -1,6 +1,7 @@ """ Click option for replacing help text option name. """ + import click diff --git a/samcli/commands/_utils/experimental.py b/samcli/commands/_utils/experimental.py index b8b75570c1..23622ec0a9 100644 --- a/samcli/commands/_utils/experimental.py +++ b/samcli/commands/_utils/experimental.py @@ -1,4 +1,5 @@ """Experimental flag""" + import logging import sys from dataclasses import dataclass diff --git a/samcli/commands/_utils/option_value_processor.py b/samcli/commands/_utils/option_value_processor.py index f117d95eb0..6625637df9 100644 --- a/samcli/commands/_utils/option_value_processor.py +++ b/samcli/commands/_utils/option_value_processor.py @@ -1,6 +1,7 @@ """ Parsing utilities commonly used to process information for commands """ + import logging from typing import Dict, Optional, Tuple diff --git a/samcli/commands/_utils/options.py b/samcli/commands/_utils/options.py index 777058216b..e2a599979a 100644 --- a/samcli/commands/_utils/options.py +++ b/samcli/commands/_utils/options.py @@ -332,9 +332,11 @@ def template_click_option(include_build=True): callback=partial(get_or_default_template_file_name, include_build=include_build), show_default=True, is_eager=True, - help="AWS SAM template which references built artifacts for resources in the template. (if applicable)" - if include_build - else "AWS SAM template file.", + help=( + "AWS SAM template which references built artifacts for resources in the template. (if applicable)" + if include_build + else "AWS SAM template file." + ), ) @@ -767,9 +769,9 @@ def hook_name_setup(f): def hook_name_processer_wrapper(f): configuration_setup_params = () configuration_setup_attrs = {} - configuration_setup_attrs[ - "help" - ] = "This is a hidden click option whose callback function to run the provided hook package." + configuration_setup_attrs["help"] = ( + "This is a hidden click option whose callback function to run the provided hook package." + ) configuration_setup_attrs["is_eager"] = True configuration_setup_attrs["expose_value"] = False configuration_setup_attrs["hidden"] = True diff --git a/samcli/commands/_utils/table_print.py b/samcli/commands/_utils/table_print.py index edb686ee6f..0e22378e98 100644 --- a/samcli/commands/_utils/table_print.py +++ b/samcli/commands/_utils/table_print.py @@ -1,6 +1,7 @@ """ Utilities for table pretty printing using click """ + import shutil import textwrap from functools import wraps diff --git a/samcli/commands/_utils/template.py b/samcli/commands/_utils/template.py index 8a45c2e0d3..622900d7e5 100644 --- a/samcli/commands/_utils/template.py +++ b/samcli/commands/_utils/template.py @@ -1,6 +1,7 @@ """ Utilities to manipulate template """ + import itertools import os import pathlib diff --git a/samcli/commands/bootstrap/command.py b/samcli/commands/bootstrap/command.py index 64c18cf8bd..4a6a4e2a27 100644 --- a/samcli/commands/bootstrap/command.py +++ b/samcli/commands/bootstrap/command.py @@ -1,6 +1,7 @@ """ CLI command for "bootstrap", which sets up a SAM development environment """ + import click from samcli.cli.main import aws_creds_options, common_options, pass_context diff --git a/samcli/commands/build/build_context.py b/samcli/commands/build/build_context.py index 7e2450a155..c976f13532 100644 --- a/samcli/commands/build/build_context.py +++ b/samcli/commands/build/build_context.py @@ -1,6 +1,7 @@ """ Context object used by build command """ + import logging import os import pathlib diff --git a/samcli/commands/build/click_container.py b/samcli/commands/build/click_container.py index 2b6273036b..8e6ad43d4b 100644 --- a/samcli/commands/build/click_container.py +++ b/samcli/commands/build/click_container.py @@ -1,6 +1,7 @@ """ Module to check container based cli parameters """ + import click diff --git a/samcli/commands/build/core/formatters.py b/samcli/commands/build/core/formatters.py index f8e2502de1..6444732a21 100644 --- a/samcli/commands/build/core/formatters.py +++ b/samcli/commands/build/core/formatters.py @@ -1,6 +1,7 @@ """ Build Command Formatter. """ + from samcli.cli.formatters import RootCommandHelpTextFormatter from samcli.cli.row_modifiers import BaseLineRowModifier from samcli.commands.build.core.options import ALL_OPTIONS diff --git a/samcli/commands/build/core/options.py b/samcli/commands/build/core/options.py index 80f3b06ebb..2da97d83ed 100644 --- a/samcli/commands/build/core/options.py +++ b/samcli/commands/build/core/options.py @@ -1,6 +1,7 @@ """ Build Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.row_modifiers import RowDefinition diff --git a/samcli/commands/build/utils.py b/samcli/commands/build/utils.py index ad84b047d4..7f5668efbf 100644 --- a/samcli/commands/build/utils.py +++ b/samcli/commands/build/utils.py @@ -1,6 +1,7 @@ """ Utilities for sam build command """ + import pathlib from enum import Enum from typing import List diff --git a/samcli/commands/delete/delete_context.py b/samcli/commands/delete/delete_context.py index 427d7fdd3f..e944eaeb8b 100644 --- a/samcli/commands/delete/delete_context.py +++ b/samcli/commands/delete/delete_context.py @@ -1,6 +1,7 @@ """ Delete a SAM stack """ + import logging from typing import Optional diff --git a/samcli/commands/delete/exceptions.py b/samcli/commands/delete/exceptions.py index 1b6a21f8bc..af034c1849 100644 --- a/samcli/commands/delete/exceptions.py +++ b/samcli/commands/delete/exceptions.py @@ -1,6 +1,7 @@ """ Exceptions that are raised by sam delete """ + from samcli.commands.exceptions import UserException diff --git a/samcli/commands/deploy/auth_utils.py b/samcli/commands/deploy/auth_utils.py index cd12c19cd6..fca6c4f478 100644 --- a/samcli/commands/deploy/auth_utils.py +++ b/samcli/commands/deploy/auth_utils.py @@ -1,6 +1,7 @@ """ Utilities for checking authorization of certain resource types """ + import logging from typing import List, Tuple diff --git a/samcli/commands/deploy/command.py b/samcli/commands/deploy/command.py index 20b9743cad..09a30ce553 100644 --- a/samcli/commands/deploy/command.py +++ b/samcli/commands/deploy/command.py @@ -1,6 +1,7 @@ """ CLI command for "deploy" command """ + import logging import os @@ -347,9 +348,11 @@ def do_cli( no_progressbar=no_progressbar, s3_prefix=guided_context.guided_s3_prefix if guided else s3_prefix, kms_key_id=kms_key_id, - parameter_overrides=sanitize_parameter_overrides(guided_context.guided_parameter_overrides) - if guided - else parameter_overrides, + parameter_overrides=( + sanitize_parameter_overrides(guided_context.guided_parameter_overrides) + if guided + else parameter_overrides + ), capabilities=guided_context.guided_capabilities if guided else capabilities, no_execute_changeset=no_execute_changeset, role_arn=role_arn, diff --git a/samcli/commands/deploy/core/options.py b/samcli/commands/deploy/core/options.py index 6c4bbdb0a0..f7e943367b 100644 --- a/samcli/commands/deploy/core/options.py +++ b/samcli/commands/deploy/core/options.py @@ -1,6 +1,7 @@ """ Deploy Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/deploy/exceptions.py b/samcli/commands/deploy/exceptions.py index a3b915259e..2cbbcd5b42 100644 --- a/samcli/commands/deploy/exceptions.py +++ b/samcli/commands/deploy/exceptions.py @@ -1,6 +1,7 @@ """ Exceptions that are raised by sam deploy """ + from samcli.commands.exceptions import UserException diff --git a/samcli/commands/deploy/guided_config.py b/samcli/commands/deploy/guided_config.py index 78866944cd..b1eacea827 100644 --- a/samcli/commands/deploy/guided_config.py +++ b/samcli/commands/deploy/guided_config.py @@ -1,6 +1,7 @@ """ Set of Utilities to deal with reading/writing to configuration file during sam deploy """ + from typing import Any import click diff --git a/samcli/commands/docs/command.py b/samcli/commands/docs/command.py index e42bef4448..303dd09fd8 100644 --- a/samcli/commands/docs/command.py +++ b/samcli/commands/docs/command.py @@ -1,6 +1,7 @@ """ CLI command for "docs" command """ + from typing import Type from click import Command, command diff --git a/samcli/commands/docs/core/command.py b/samcli/commands/docs/core/command.py index a22b98e42e..4cb362330c 100644 --- a/samcli/commands/docs/core/command.py +++ b/samcli/commands/docs/core/command.py @@ -1,6 +1,7 @@ """ Module contains classes for creating the docs command from click """ + import os from typing import List, Optional diff --git a/samcli/commands/docs/core/formatter.py b/samcli/commands/docs/core/formatter.py index e11a168def..99f3c6a920 100644 --- a/samcli/commands/docs/core/formatter.py +++ b/samcli/commands/docs/core/formatter.py @@ -1,6 +1,7 @@ """ Base formatter for the docs command help text """ + from samcli.cli.formatters import RootCommandHelpTextFormatter from samcli.cli.row_modifiers import BaseLineRowModifier diff --git a/samcli/commands/exceptions.py b/samcli/commands/exceptions.py index b5e8e516eb..d8708c9272 100644 --- a/samcli/commands/exceptions.py +++ b/samcli/commands/exceptions.py @@ -1,6 +1,7 @@ """ Class containing error conditions that are exposed to the user. """ + import traceback from typing import IO, Optional from urllib.parse import quote diff --git a/samcli/commands/init/__init__.py b/samcli/commands/init/__init__.py index 6a88e92de2..7f72e7f7fd 100644 --- a/samcli/commands/init/__init__.py +++ b/samcli/commands/init/__init__.py @@ -1,4 +1,5 @@ """ Expose top level cli command for `init` """ + from .command import cli diff --git a/samcli/commands/init/command.py b/samcli/commands/init/command.py index 6f60ca1d86..e1d1c717b7 100644 --- a/samcli/commands/init/command.py +++ b/samcli/commands/init/command.py @@ -1,6 +1,7 @@ """ Init command to scaffold a project app from a template """ + import json import logging from json import JSONDecodeError diff --git a/samcli/commands/init/core/options.py b/samcli/commands/init/core/options.py index 586c919ba5..291c2801a3 100644 --- a/samcli/commands/init/core/options.py +++ b/samcli/commands/init/core/options.py @@ -1,6 +1,7 @@ """ Init Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/init/init_flow_helpers.py b/samcli/commands/init/init_flow_helpers.py index 6ca7352b1b..fe8d41b623 100644 --- a/samcli/commands/init/init_flow_helpers.py +++ b/samcli/commands/init/init_flow_helpers.py @@ -1,6 +1,7 @@ """ Init flow based helper functions """ + import functools import logging import re diff --git a/samcli/commands/init/init_templates.py b/samcli/commands/init/init_templates.py index f2744c8da6..b1d1d55a01 100644 --- a/samcli/commands/init/init_templates.py +++ b/samcli/commands/init/init_templates.py @@ -1,6 +1,7 @@ """ Manages the set of application templates. """ + import itertools import json import logging diff --git a/samcli/commands/init/interactive_init_flow.py b/samcli/commands/init/interactive_init_flow.py index 8f724dbed1..57a1c1f64b 100644 --- a/samcli/commands/init/interactive_init_flow.py +++ b/samcli/commands/init/interactive_init_flow.py @@ -1,6 +1,7 @@ """ Isolates interactive init prompt flow. Expected to call generator logic at end of flow. """ + import logging import pathlib import tempfile diff --git a/samcli/commands/list/cli_common/list_common_context.py b/samcli/commands/list/cli_common/list_common_context.py index 455314ec19..e51c8de07f 100644 --- a/samcli/commands/list/cli_common/list_common_context.py +++ b/samcli/commands/list/cli_common/list_common_context.py @@ -1,6 +1,7 @@ """ Common context class to inherit from for sam list sub-commands """ + from samcli.lib.utils.boto_utils import get_boto_client_provider_with_config diff --git a/samcli/commands/list/endpoints/endpoints_context.py b/samcli/commands/list/endpoints/endpoints_context.py index 9f31eff9ce..3f5b932e61 100644 --- a/samcli/commands/list/endpoints/endpoints_context.py +++ b/samcli/commands/list/endpoints/endpoints_context.py @@ -1,6 +1,7 @@ """ Display of the Endpoints of a SAM stack """ + import logging from typing import Optional diff --git a/samcli/commands/list/exceptions.py b/samcli/commands/list/exceptions.py index 9269249d0e..b0ecb9a8d1 100644 --- a/samcli/commands/list/exceptions.py +++ b/samcli/commands/list/exceptions.py @@ -2,7 +2,6 @@ Exceptions for SAM list """ - from samcli.commands.exceptions import UserException diff --git a/samcli/commands/list/json_consumer.py b/samcli/commands/list/json_consumer.py index 0153830ac6..78d54810a5 100644 --- a/samcli/commands/list/json_consumer.py +++ b/samcli/commands/list/json_consumer.py @@ -1,6 +1,7 @@ """ The json consumer for 'sam list' """ + import click from samcli.lib.list.list_interfaces import ListInfoPullerConsumer diff --git a/samcli/commands/list/resources/resources_context.py b/samcli/commands/list/resources/resources_context.py index ea971bc7b1..ba8e5d1dbe 100644 --- a/samcli/commands/list/resources/resources_context.py +++ b/samcli/commands/list/resources/resources_context.py @@ -1,6 +1,7 @@ """ Display the Resources of a SAM stack """ + import logging from typing import Optional diff --git a/samcli/commands/list/stack_outputs/stack_outputs_context.py b/samcli/commands/list/stack_outputs/stack_outputs_context.py index efd40eed8a..ab8a922bbb 100644 --- a/samcli/commands/list/stack_outputs/stack_outputs_context.py +++ b/samcli/commands/list/stack_outputs/stack_outputs_context.py @@ -1,6 +1,7 @@ """ Display the Outputs of a SAM stack """ + import logging from typing import Optional diff --git a/samcli/commands/list/table_consumer.py b/samcli/commands/list/table_consumer.py index e39915b2f3..f6c70136de 100644 --- a/samcli/commands/list/table_consumer.py +++ b/samcli/commands/list/table_consumer.py @@ -1,6 +1,7 @@ """ The table consumer for 'sam list' """ + from typing import Any, Dict from samcli.commands._utils.table_print import pprint_column_names, pprint_columns diff --git a/samcli/commands/local/cli_common/invoke_context.py b/samcli/commands/local/cli_common/invoke_context.py index fc7ca7020d..9255761143 100644 --- a/samcli/commands/local/cli_common/invoke_context.py +++ b/samcli/commands/local/cli_common/invoke_context.py @@ -1,6 +1,7 @@ """ Reads CLI arguments and performs necessary preparation to be able to run the function """ + import errno import json import logging diff --git a/samcli/commands/local/cli_common/options.py b/samcli/commands/local/cli_common/options.py index a525fb463c..8550a8ba95 100644 --- a/samcli/commands/local/cli_common/options.py +++ b/samcli/commands/local/cli_common/options.py @@ -1,6 +1,7 @@ """ Common CLI options for invoke command """ + from pathlib import Path import click diff --git a/samcli/commands/local/generate_event/core/command.py b/samcli/commands/local/generate_event/core/command.py index 1fd17d4a46..2303867218 100644 --- a/samcli/commands/local/generate_event/core/command.py +++ b/samcli/commands/local/generate_event/core/command.py @@ -1,6 +1,7 @@ """ Generate Event Command Class. """ + from click import Context, style from samcli.cli.core.command import CoreCommand diff --git a/samcli/commands/local/invoke/core/command.py b/samcli/commands/local/invoke/core/command.py index 3551530462..1d4f9ce3f5 100644 --- a/samcli/commands/local/invoke/core/command.py +++ b/samcli/commands/local/invoke/core/command.py @@ -1,6 +1,7 @@ """ Invoke Command Class. """ + import json from click import Context, style diff --git a/samcli/commands/local/invoke/core/formatters.py b/samcli/commands/local/invoke/core/formatters.py index bad4eb881b..b08fd9bcb4 100644 --- a/samcli/commands/local/invoke/core/formatters.py +++ b/samcli/commands/local/invoke/core/formatters.py @@ -1,6 +1,7 @@ """ Invoke Command Formatter. """ + from samcli.cli.formatters import RootCommandHelpTextFormatter from samcli.cli.row_modifiers import BaseLineRowModifier from samcli.commands.local.invoke.core.options import ALL_OPTIONS diff --git a/samcli/commands/local/invoke/core/options.py b/samcli/commands/local/invoke/core/options.py index ff23f857f5..dbd9b652eb 100644 --- a/samcli/commands/local/invoke/core/options.py +++ b/samcli/commands/local/invoke/core/options.py @@ -1,6 +1,7 @@ """ Invoke Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/local/lib/exceptions.py b/samcli/commands/local/lib/exceptions.py index 7d739f3ef2..c19b694d60 100644 --- a/samcli/commands/local/lib/exceptions.py +++ b/samcli/commands/local/lib/exceptions.py @@ -1,6 +1,7 @@ """ Custom exceptions raised by this local library """ + from samcli.commands.exceptions import UserException diff --git a/samcli/commands/local/lib/local_lambda_service.py b/samcli/commands/local/lib/local_lambda_service.py index 0d493c2ff8..9b4083dcc6 100644 --- a/samcli/commands/local/lib/local_lambda_service.py +++ b/samcli/commands/local/lib/local_lambda_service.py @@ -1,6 +1,7 @@ """ Connects the CLI with Local Lambda Invoke Service. """ + import logging from samcli.local.lambda_service.local_lambda_invoke_service import LocalLambdaInvokeService diff --git a/samcli/commands/local/lib/validators/identity_source_validator.py b/samcli/commands/local/lib/validators/identity_source_validator.py index e95cc6a316..d9c45b5cf3 100644 --- a/samcli/commands/local/lib/validators/identity_source_validator.py +++ b/samcli/commands/local/lib/validators/identity_source_validator.py @@ -1,6 +1,7 @@ """ Handles the validation of identity sources """ + import re from samcli.local.apigw.route import Route diff --git a/samcli/commands/local/lib/validators/lambda_auth_props.py b/samcli/commands/local/lib/validators/lambda_auth_props.py index 96a9ce05b1..7c111b02fc 100644 --- a/samcli/commands/local/lib/validators/lambda_auth_props.py +++ b/samcli/commands/local/lib/validators/lambda_auth_props.py @@ -1,6 +1,7 @@ """ Module to help validate Lambda Authorizer properties """ + import logging from abc import ABC, abstractmethod diff --git a/samcli/commands/local/start_api/core/formatters.py b/samcli/commands/local/start_api/core/formatters.py index 79b2536a0b..a353c2d781 100644 --- a/samcli/commands/local/start_api/core/formatters.py +++ b/samcli/commands/local/start_api/core/formatters.py @@ -1,6 +1,7 @@ """ Invoke API Command Formatter. """ + from samcli.cli.formatters import RootCommandHelpTextFormatter from samcli.cli.row_modifiers import BaseLineRowModifier from samcli.commands.local.start_api.core.options import ALL_OPTIONS diff --git a/samcli/commands/local/start_api/core/options.py b/samcli/commands/local/start_api/core/options.py index 5a5c7ca23d..01b79ae7b7 100644 --- a/samcli/commands/local/start_api/core/options.py +++ b/samcli/commands/local/start_api/core/options.py @@ -1,6 +1,7 @@ """ Invoke Start API Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/local/start_lambda/core/formatters.py b/samcli/commands/local/start_lambda/core/formatters.py index 6e8eae4322..11f0f66ffd 100644 --- a/samcli/commands/local/start_lambda/core/formatters.py +++ b/samcli/commands/local/start_lambda/core/formatters.py @@ -1,6 +1,7 @@ """ Invoke Lambda Command Formatter. """ + from samcli.cli.formatters import RootCommandHelpTextFormatter from samcli.cli.row_modifiers import BaseLineRowModifier from samcli.commands.local.start_lambda.core.options import ALL_OPTIONS diff --git a/samcli/commands/local/start_lambda/core/options.py b/samcli/commands/local/start_lambda/core/options.py index 1a35f564ea..88bd7e0a22 100644 --- a/samcli/commands/local/start_lambda/core/options.py +++ b/samcli/commands/local/start_lambda/core/options.py @@ -1,6 +1,7 @@ """ Invoke Start Lambda Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/logs/core/options.py b/samcli/commands/logs/core/options.py index 715111cd42..901fc9f652 100644 --- a/samcli/commands/logs/core/options.py +++ b/samcli/commands/logs/core/options.py @@ -1,6 +1,7 @@ """ Logs Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/logs/puller_factory.py b/samcli/commands/logs/puller_factory.py index c322a44819..1bb50237c8 100644 --- a/samcli/commands/logs/puller_factory.py +++ b/samcli/commands/logs/puller_factory.py @@ -2,6 +2,7 @@ File keeps Factory method to prepare required puller information with its producers and consumers """ + import logging from typing import List, Optional diff --git a/samcli/commands/logs/validation_and_exception_handlers.py b/samcli/commands/logs/validation_and_exception_handlers.py index 48ef9a0193..461fd3f2f7 100644 --- a/samcli/commands/logs/validation_and_exception_handlers.py +++ b/samcli/commands/logs/validation_and_exception_handlers.py @@ -1,6 +1,7 @@ """ Contains helper functions for validation and exception handling of "sam logs" command """ + from functools import wraps from typing import Any, Callable, Dict diff --git a/samcli/commands/package/command.py b/samcli/commands/package/command.py index 249aee5cfb..994f3a3ffe 100644 --- a/samcli/commands/package/command.py +++ b/samcli/commands/package/command.py @@ -1,6 +1,7 @@ """ CLI command for "package" command """ + import click from samcli.cli.cli_config_file import ConfigProvider, configuration_option, save_params_option diff --git a/samcli/commands/package/core/command.py b/samcli/commands/package/core/command.py index 16a9ee3d2a..e0f1056ec1 100644 --- a/samcli/commands/package/core/command.py +++ b/samcli/commands/package/core/command.py @@ -1,6 +1,7 @@ """ `sam package` command class for help text visual layer. """ + import click from click import Context, style from rich.table import Table diff --git a/samcli/commands/package/core/options.py b/samcli/commands/package/core/options.py index 6dc97001a0..37ea91379e 100644 --- a/samcli/commands/package/core/options.py +++ b/samcli/commands/package/core/options.py @@ -1,6 +1,7 @@ """ Package Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/package/exceptions.py b/samcli/commands/package/exceptions.py index f5fdee0297..a781960117 100644 --- a/samcli/commands/package/exceptions.py +++ b/samcli/commands/package/exceptions.py @@ -1,6 +1,7 @@ """ Exceptions that are raised by sam package """ + from samcli.commands.exceptions import UserException diff --git a/samcli/commands/pipeline/bootstrap/cli.py b/samcli/commands/pipeline/bootstrap/cli.py index 991d0a6269..36438b5efc 100644 --- a/samcli/commands/pipeline/bootstrap/cli.py +++ b/samcli/commands/pipeline/bootstrap/cli.py @@ -1,6 +1,7 @@ """ CLI command for "pipeline bootstrap", which sets up the require pipeline infrastructure resources """ + import os from textwrap import dedent from typing import Any, Dict, List, Optional diff --git a/samcli/commands/pipeline/bootstrap/guided_context.py b/samcli/commands/pipeline/bootstrap/guided_context.py index fec10ba142..0847c028fd 100644 --- a/samcli/commands/pipeline/bootstrap/guided_context.py +++ b/samcli/commands/pipeline/bootstrap/guided_context.py @@ -2,6 +2,7 @@ An interactive flow that prompt the user for required information to bootstrap the AWS account of an environment with the required infrastructure """ + import os import sys from textwrap import dedent @@ -317,9 +318,11 @@ def _get_user_inputs(self) -> List[Tuple[str, Callable[[], None]]]: inputs.extend( [ ( - f"Pipeline user ARN: {self.pipeline_user_arn}" - if self.pipeline_user_arn - else "Pipeline user: [to be created]", + ( + f"Pipeline user ARN: {self.pipeline_user_arn}" + if self.pipeline_user_arn + else "Pipeline user: [to be created]" + ), self._prompt_pipeline_user, ) ] @@ -328,27 +331,35 @@ def _get_user_inputs(self) -> List[Tuple[str, Callable[[], None]]]: inputs.extend( [ ( - f"Pipeline execution role ARN: {self.pipeline_execution_role_arn}" - if self.pipeline_execution_role_arn - else "Pipeline execution role: [to be created]", + ( + f"Pipeline execution role ARN: {self.pipeline_execution_role_arn}" + if self.pipeline_execution_role_arn + else "Pipeline execution role: [to be created]" + ), self._prompt_pipeline_execution_role, ), ( - f"CloudFormation execution role ARN: {self.cloudformation_execution_role_arn}" - if self.cloudformation_execution_role_arn - else "CloudFormation execution role: [to be created]", + ( + f"CloudFormation execution role ARN: {self.cloudformation_execution_role_arn}" + if self.cloudformation_execution_role_arn + else "CloudFormation execution role: [to be created]" + ), self._prompt_cloudformation_execution_role, ), ( - f"Artifacts bucket ARN: {self.artifacts_bucket_arn}" - if self.artifacts_bucket_arn - else "Artifacts bucket: [to be created]", + ( + f"Artifacts bucket ARN: {self.artifacts_bucket_arn}" + if self.artifacts_bucket_arn + else "Artifacts bucket: [to be created]" + ), self._prompt_artifacts_bucket, ), ( - f"ECR image repository ARN: {self.image_repository_arn}" - if self.image_repository_arn - else f"ECR image repository: [{'to be created' if self.create_image_repository else 'skipped'}]", + ( + f"ECR image repository ARN: {self.image_repository_arn}" + if self.image_repository_arn + else f"ECR image repository: [{'to be created' if self.create_image_repository else 'skipped'}]" + ), self._prompt_image_repository, ), ] diff --git a/samcli/commands/pipeline/bootstrap/oidc_config.py b/samcli/commands/pipeline/bootstrap/oidc_config.py index 776b69abe8..427a6cce75 100644 --- a/samcli/commands/pipeline/bootstrap/oidc_config.py +++ b/samcli/commands/pipeline/bootstrap/oidc_config.py @@ -1,6 +1,7 @@ """ Represents a pipeline OIDC provider """ + from dataclasses import dataclass from typing import Optional diff --git a/samcli/commands/pipeline/bootstrap/pipeline_oidc_provider.py b/samcli/commands/pipeline/bootstrap/pipeline_oidc_provider.py index b45f4171ca..45b1ccec18 100644 --- a/samcli/commands/pipeline/bootstrap/pipeline_oidc_provider.py +++ b/samcli/commands/pipeline/bootstrap/pipeline_oidc_provider.py @@ -1,6 +1,7 @@ """ Represents a pipeline OIDC provider """ + from abc import abstractmethod from typing import List diff --git a/samcli/commands/pipeline/external_links.py b/samcli/commands/pipeline/external_links.py index 77301ebb1b..f4e8978c73 100644 --- a/samcli/commands/pipeline/external_links.py +++ b/samcli/commands/pipeline/external_links.py @@ -2,6 +2,7 @@ The module to store external links. Put them in a centralized place so that we can verify their validity automatically. """ + CONFIG_AWS_CRED_DOC_URL = "https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html" _SAM_DOC_PREFIX = "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide" diff --git a/samcli/commands/pipeline/init/cli.py b/samcli/commands/pipeline/init/cli.py index 416c1c8fdf..de1f20851e 100644 --- a/samcli/commands/pipeline/init/cli.py +++ b/samcli/commands/pipeline/init/cli.py @@ -1,6 +1,7 @@ """ CLI command for "pipeline init" command """ + from typing import Any, Optional import click diff --git a/samcli/commands/pipeline/init/interactive_init_flow.py b/samcli/commands/pipeline/init/interactive_init_flow.py index b6c93acc4f..ce29274c3c 100644 --- a/samcli/commands/pipeline/init/interactive_init_flow.py +++ b/samcli/commands/pipeline/init/interactive_init_flow.py @@ -2,6 +2,7 @@ Interactive flow that prompts that users for pipeline template (cookiecutter template) and used it to generate pipeline configuration file """ + import json import logging import os diff --git a/samcli/commands/pipeline/init/pipeline_templates_manifest.py b/samcli/commands/pipeline/init/pipeline_templates_manifest.py index e9729511fa..64b87876a8 100644 --- a/samcli/commands/pipeline/init/pipeline_templates_manifest.py +++ b/samcli/commands/pipeline/init/pipeline_templates_manifest.py @@ -19,6 +19,7 @@ provider: Github Actions location: templates/cookiecutter-github-actions-two-environments-pipeline """ + from pathlib import Path from typing import Dict, List diff --git a/samcli/commands/remote/exceptions.py b/samcli/commands/remote/exceptions.py index fc913e7e60..3e6df6b588 100644 --- a/samcli/commands/remote/exceptions.py +++ b/samcli/commands/remote/exceptions.py @@ -1,6 +1,7 @@ """ Exceptions that are used by remote invoke or remote test-events commands """ + from samcli.commands.exceptions import UserException diff --git a/samcli/commands/remote/invoke/cli.py b/samcli/commands/remote/invoke/cli.py index c1c08b3fe0..2d7d3ef71b 100644 --- a/samcli/commands/remote/invoke/cli.py +++ b/samcli/commands/remote/invoke/cli.py @@ -1,4 +1,5 @@ """CLI command for "invoke" command.""" + import logging from io import TextIOWrapper diff --git a/samcli/commands/remote/invoke/core/command.py b/samcli/commands/remote/invoke/core/command.py index 6c6912e937..f0137dcaff 100644 --- a/samcli/commands/remote/invoke/core/command.py +++ b/samcli/commands/remote/invoke/core/command.py @@ -1,6 +1,7 @@ """ Invoke Command Class. """ + import json from click import Context, style diff --git a/samcli/commands/remote/invoke/core/formatters.py b/samcli/commands/remote/invoke/core/formatters.py index ee8cee01aa..df1d723ab1 100644 --- a/samcli/commands/remote/invoke/core/formatters.py +++ b/samcli/commands/remote/invoke/core/formatters.py @@ -1,6 +1,7 @@ """ Remote Invoke Command Formatter. """ + from samcli.cli.formatters import RootCommandHelpTextFormatter from samcli.cli.row_modifiers import BaseLineRowModifier from samcli.commands.remote.invoke.core.options import ALL_OPTIONS diff --git a/samcli/commands/remote/invoke/core/options.py b/samcli/commands/remote/invoke/core/options.py index 7d9008ffe3..d22f223ae4 100644 --- a/samcli/commands/remote/invoke/core/options.py +++ b/samcli/commands/remote/invoke/core/options.py @@ -1,6 +1,7 @@ """ Remote Invoke Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/remote/remote_invoke_context.py b/samcli/commands/remote/remote_invoke_context.py index bf98b6317a..cc5dedddb8 100644 --- a/samcli/commands/remote/remote_invoke_context.py +++ b/samcli/commands/remote/remote_invoke_context.py @@ -1,6 +1,7 @@ """ Context object used by `sam remote invoke` command """ + import logging from dataclasses import dataclass from typing import Optional, cast diff --git a/samcli/commands/remote/test_event/core/base_options.py b/samcli/commands/remote/test_event/core/base_options.py index 5b4edd0d0d..dacc6a5c45 100644 --- a/samcli/commands/remote/test_event/core/base_options.py +++ b/samcli/commands/remote/test_event/core/base_options.py @@ -1,6 +1,7 @@ """ Remote Test Event Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.row_modifiers import RowDefinition diff --git a/samcli/commands/remote/test_event/core/formatters.py b/samcli/commands/remote/test_event/core/formatters.py index 73a295ad3d..26ea664739 100644 --- a/samcli/commands/remote/test_event/core/formatters.py +++ b/samcli/commands/remote/test_event/core/formatters.py @@ -1,6 +1,7 @@ """ Remote Test Event Command Formatter base. """ + from typing import List from samcli.cli.formatters import RootCommandHelpTextFormatter diff --git a/samcli/commands/remote/test_event/delete/core/command.py b/samcli/commands/remote/test_event/delete/core/command.py index 15cd46a9e8..f928cadfd3 100644 --- a/samcli/commands/remote/test_event/delete/core/command.py +++ b/samcli/commands/remote/test_event/delete/core/command.py @@ -1,6 +1,7 @@ """ Delete Test Event Command Class. """ + from click import Context, style from samcli.cli.core.command import CoreCommand diff --git a/samcli/commands/remote/test_event/delete/core/options.py b/samcli/commands/remote/test_event/delete/core/options.py index 820e58275f..7ae49a3c79 100644 --- a/samcli/commands/remote/test_event/delete/core/options.py +++ b/samcli/commands/remote/test_event/delete/core/options.py @@ -1,6 +1,7 @@ """ Delete Remote Test Event Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, add_common_options_info diff --git a/samcli/commands/remote/test_event/get/cli.py b/samcli/commands/remote/test_event/get/cli.py index 85f6e68d51..e8685ca41a 100644 --- a/samcli/commands/remote/test_event/get/cli.py +++ b/samcli/commands/remote/test_event/get/cli.py @@ -1,4 +1,5 @@ """CLI command for "test-event get" command.""" + import logging import sys from io import TextIOWrapper diff --git a/samcli/commands/remote/test_event/get/core/command.py b/samcli/commands/remote/test_event/get/core/command.py index 0d029a805d..b68f0f4648 100644 --- a/samcli/commands/remote/test_event/get/core/command.py +++ b/samcli/commands/remote/test_event/get/core/command.py @@ -1,6 +1,7 @@ """ Get Test Event Command Class. """ + from click import Context, style from samcli.cli.core.command import CoreCommand diff --git a/samcli/commands/remote/test_event/get/core/formatters.py b/samcli/commands/remote/test_event/get/core/formatters.py index 857f06b31b..491ecad6e9 100644 --- a/samcli/commands/remote/test_event/get/core/formatters.py +++ b/samcli/commands/remote/test_event/get/core/formatters.py @@ -1,6 +1,7 @@ """ Get Test Event Command Formatter. """ + from samcli.commands.remote.test_event.core.formatters import RemoteTestEventCommandHelpTextFormatter from samcli.commands.remote.test_event.get.core.options import ALL_OPTIONS diff --git a/samcli/commands/remote/test_event/get/core/options.py b/samcli/commands/remote/test_event/get/core/options.py index b3d1514275..449399e42c 100644 --- a/samcli/commands/remote/test_event/get/core/options.py +++ b/samcli/commands/remote/test_event/get/core/options.py @@ -1,6 +1,7 @@ """ Get Remote Test Event Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, add_common_options_info diff --git a/samcli/commands/remote/test_event/list/core/command.py b/samcli/commands/remote/test_event/list/core/command.py index fa0ca88489..1942629986 100644 --- a/samcli/commands/remote/test_event/list/core/command.py +++ b/samcli/commands/remote/test_event/list/core/command.py @@ -1,6 +1,7 @@ """ List Test Event Command Class. """ + from click import Context, style from samcli.cli.core.command import CoreCommand diff --git a/samcli/commands/remote/test_event/list/core/formatters.py b/samcli/commands/remote/test_event/list/core/formatters.py index 25bcaaac42..d632abe2f7 100644 --- a/samcli/commands/remote/test_event/list/core/formatters.py +++ b/samcli/commands/remote/test_event/list/core/formatters.py @@ -1,6 +1,7 @@ """ List Test Events Command Formatter. """ + from samcli.commands.remote.test_event.core.formatters import RemoteTestEventCommandHelpTextFormatter from samcli.commands.remote.test_event.list.core.options import ALL_OPTIONS diff --git a/samcli/commands/remote/test_event/list/core/options.py b/samcli/commands/remote/test_event/list/core/options.py index 21e1f068a3..659d0a7d39 100644 --- a/samcli/commands/remote/test_event/list/core/options.py +++ b/samcli/commands/remote/test_event/list/core/options.py @@ -1,6 +1,7 @@ """ List Remote Test Events Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, add_common_options_info diff --git a/samcli/commands/remote/test_event/put/cli.py b/samcli/commands/remote/test_event/put/cli.py index 03426b51ec..df98670c35 100644 --- a/samcli/commands/remote/test_event/put/cli.py +++ b/samcli/commands/remote/test_event/put/cli.py @@ -1,4 +1,5 @@ """CLI command for "test-event put" command.""" + import logging import sys from io import TextIOWrapper diff --git a/samcli/commands/remote/test_event/put/core/command.py b/samcli/commands/remote/test_event/put/core/command.py index 631e758ab6..3740e75776 100644 --- a/samcli/commands/remote/test_event/put/core/command.py +++ b/samcli/commands/remote/test_event/put/core/command.py @@ -1,6 +1,7 @@ """ Put Test Event Command Class. """ + import json from click import Context, style diff --git a/samcli/commands/remote/test_event/put/core/formatters.py b/samcli/commands/remote/test_event/put/core/formatters.py index 2967f4d223..a5ee6315f7 100644 --- a/samcli/commands/remote/test_event/put/core/formatters.py +++ b/samcli/commands/remote/test_event/put/core/formatters.py @@ -1,6 +1,7 @@ """ Put Test Event Command Formatter. """ + from samcli.commands.remote.test_event.core.formatters import RemoteTestEventCommandHelpTextFormatter from samcli.commands.remote.test_event.put.core.options import ALL_OPTIONS diff --git a/samcli/commands/remote/test_event/put/core/options.py b/samcli/commands/remote/test_event/put/core/options.py index 3b2a0c61ec..a428a7c16d 100644 --- a/samcli/commands/remote/test_event/put/core/options.py +++ b/samcli/commands/remote/test_event/put/core/options.py @@ -1,6 +1,7 @@ """ Put Remote Test Event Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, add_common_options_info diff --git a/samcli/commands/remote/test_event/test_event.py b/samcli/commands/remote/test_event/test_event.py index 5916378aaa..f725fad602 100644 --- a/samcli/commands/remote/test_event/test_event.py +++ b/samcli/commands/remote/test_event/test_event.py @@ -1,4 +1,5 @@ """Command group for "test-event" suite of commands.""" + import click from samcli.commands.remote.test_event.delete.cli import cli as delete_cli diff --git a/samcli/commands/sync/command.py b/samcli/commands/sync/command.py index dfafae7ea4..edbcb98e85 100644 --- a/samcli/commands/sync/command.py +++ b/samcli/commands/sync/command.py @@ -1,4 +1,5 @@ """CLI command for "sync" command.""" + import logging import os from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple diff --git a/samcli/commands/sync/core/command.py b/samcli/commands/sync/core/command.py index e498c1cfe7..d5fbbbee41 100644 --- a/samcli/commands/sync/core/command.py +++ b/samcli/commands/sync/core/command.py @@ -1,6 +1,7 @@ """ Sync Command Class. """ + from click import Context, style from samcli.cli.core.command import CoreCommand diff --git a/samcli/commands/sync/core/formatters.py b/samcli/commands/sync/core/formatters.py index 81791e802d..a9dec82f76 100644 --- a/samcli/commands/sync/core/formatters.py +++ b/samcli/commands/sync/core/formatters.py @@ -1,6 +1,7 @@ """ Sync Command Formatter. """ + from samcli.cli.formatters import RootCommandHelpTextFormatter from samcli.cli.row_modifiers import BaseLineRowModifier from samcli.commands.sync.core.options import ALL_OPTIONS diff --git a/samcli/commands/sync/core/options.py b/samcli/commands/sync/core/options.py index c03e6ef190..509261025c 100644 --- a/samcli/commands/sync/core/options.py +++ b/samcli/commands/sync/core/options.py @@ -1,6 +1,7 @@ """ Sync Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/sync/sync_context.py b/samcli/commands/sync/sync_context.py index a9541d3fcf..c0c75705a5 100644 --- a/samcli/commands/sync/sync_context.py +++ b/samcli/commands/sync/sync_context.py @@ -1,6 +1,7 @@ """ Context object used by sync command """ + import logging import threading from dataclasses import dataclass diff --git a/samcli/commands/traces/command.py b/samcli/commands/traces/command.py index 783ac63d43..e3f1f3a561 100644 --- a/samcli/commands/traces/command.py +++ b/samcli/commands/traces/command.py @@ -1,6 +1,7 @@ """ CLI command for "traces" command """ + import logging import click diff --git a/samcli/commands/traces/traces_puller_factory.py b/samcli/commands/traces/traces_puller_factory.py index ae6e0bfb1d..11a6ca5814 100644 --- a/samcli/commands/traces/traces_puller_factory.py +++ b/samcli/commands/traces/traces_puller_factory.py @@ -1,6 +1,7 @@ """ Factory methods which generates puller and consumer instances for XRay events """ + from typing import Any, List from samcli.commands.traces.trace_console_consumers import XRayTraceConsoleConsumer diff --git a/samcli/commands/validate/core/formatters.py b/samcli/commands/validate/core/formatters.py index 4cabeb568c..69f12b0a4b 100644 --- a/samcli/commands/validate/core/formatters.py +++ b/samcli/commands/validate/core/formatters.py @@ -1,6 +1,7 @@ """ Validate Command Formatter. """ + from samcli.cli.formatters import RootCommandHelpTextFormatter from samcli.cli.row_modifiers import BaseLineRowModifier from samcli.commands.validate.core.options import ALL_OPTIONS diff --git a/samcli/commands/validate/core/options.py b/samcli/commands/validate/core/options.py index 7e4993e130..61eb1d0abf 100644 --- a/samcli/commands/validate/core/options.py +++ b/samcli/commands/validate/core/options.py @@ -1,6 +1,7 @@ """ Validate Command Options related Datastructures for formatting. """ + from typing import Dict, List from samcli.cli.core.options import ALL_COMMON_OPTIONS, SAVE_PARAMS_OPTIONS, add_common_options_info diff --git a/samcli/commands/validate/validate.py b/samcli/commands/validate/validate.py index c47e205d8c..db0a130b24 100644 --- a/samcli/commands/validate/validate.py +++ b/samcli/commands/validate/validate.py @@ -1,6 +1,7 @@ """ CLI Command for Validating a SAM Template """ + import os import boto3 diff --git a/samcli/hook_packages/terraform/__init__.py b/samcli/hook_packages/terraform/__init__.py index 5dbd4c5c5d..e75196dfb6 100644 --- a/samcli/hook_packages/terraform/__init__.py +++ b/samcli/hook_packages/terraform/__init__.py @@ -1,4 +1,5 @@ """ Expose top level prepare hook """ + from .main import prepare diff --git a/samcli/hook_packages/terraform/hooks/prepare/constants.py b/samcli/hook_packages/terraform/hooks/prepare/constants.py index e6ea7a1fca..afa6876768 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/constants.py +++ b/samcli/hook_packages/terraform/hooks/prepare/constants.py @@ -1,6 +1,7 @@ """ Constants related to the Terraform prepare hook. """ + import re from samcli.lib.utils.resources import AWS_LAMBDA_FUNCTION as CFN_AWS_LAMBDA_FUNCTION diff --git a/samcli/hook_packages/terraform/hooks/prepare/enrich.py b/samcli/hook_packages/terraform/hooks/prepare/enrich.py index 9b27d91ccf..5ca32ae075 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/enrich.py +++ b/samcli/hook_packages/terraform/hooks/prepare/enrich.py @@ -3,6 +3,7 @@ This module populates the values required for each of the Lambda resources """ + import json import logging import os diff --git a/samcli/hook_packages/terraform/hooks/prepare/exceptions.py b/samcli/hook_packages/terraform/hooks/prepare/exceptions.py index 3a8d9c2b67..3074301272 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/exceptions.py +++ b/samcli/hook_packages/terraform/hooks/prepare/exceptions.py @@ -1,6 +1,7 @@ """ Module containing prepare hook-related exceptions """ + import os from samcli.commands.exceptions import UserException diff --git a/samcli/hook_packages/terraform/hooks/prepare/hook.py b/samcli/hook_packages/terraform/hooks/prepare/hook.py index 76a730cb54..e287893ee3 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/hook.py +++ b/samcli/hook_packages/terraform/hooks/prepare/hook.py @@ -3,6 +3,7 @@ This module contains the main prepare method """ + import json import logging import os diff --git a/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py b/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py index f9606ffbd3..ab0615bf0f 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py +++ b/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py @@ -3,6 +3,7 @@ This module generates the Makefile for the project and the rules for each of the Lambda functions found """ + import logging import os import shutil diff --git a/samcli/hook_packages/terraform/hooks/prepare/property_builder.py b/samcli/hook_packages/terraform/hooks/prepare/property_builder.py index efb88bedf3..bdbd1c7d24 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/property_builder.py +++ b/samcli/hook_packages/terraform/hooks/prepare/property_builder.py @@ -1,6 +1,7 @@ """ Terraform prepare property builder """ + import logging from json import loads from json.decoder import JSONDecodeError diff --git a/samcli/hook_packages/terraform/hooks/prepare/resource_linking.py b/samcli/hook_packages/terraform/hooks/prepare/resource_linking.py index a7fbadd4e2..7b1e339644 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/resource_linking.py +++ b/samcli/hook_packages/terraform/hooks/prepare/resource_linking.py @@ -2,6 +2,7 @@ Use Terraform plan to link resources together e.g. linking layers to functions """ + import logging import re from dataclasses import dataclass @@ -157,9 +158,9 @@ class ResourceLinkingPair: cfn_resource_update_call_back_function: Callable[[Dict, List[ReferenceType]], None] linking_exceptions: ResourcePairExceptions # function to extract the terraform destination value from the linking field value - tf_destination_value_extractor_from_link_field_value_function: Callable[ - [str], str - ] = _default_tf_destination_value_id_extractor + tf_destination_value_extractor_from_link_field_value_function: Callable[[str], str] = ( + _default_tf_destination_value_id_extractor + ) class ResourceLinker: @@ -357,12 +358,14 @@ def _link_using_linking_fields(self, cfn_resource: Dict) -> None: ) dest_resources = [ - LogicalIdReference( - value=child_resources_linking_attributes_logical_id_mapping[value][0], - resource_type=child_resources_linking_attributes_logical_id_mapping[value][1], + ( + LogicalIdReference( + value=child_resources_linking_attributes_logical_id_mapping[value][0], + resource_type=child_resources_linking_attributes_logical_id_mapping[value][1], + ) + if value in child_resources_linking_attributes_logical_id_mapping + else ExistingResourceReference(value) ) - if value in child_resources_linking_attributes_logical_id_mapping - else ExistingResourceReference(value) for value in values ] diff --git a/samcli/hook_packages/terraform/hooks/prepare/resources/code_resource_utils.py b/samcli/hook_packages/terraform/hooks/prepare/resources/code_resource_utils.py index f496409cbc..88eb44d1c5 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/resources/code_resource_utils.py +++ b/samcli/hook_packages/terraform/hooks/prepare/resources/code_resource_utils.py @@ -1,6 +1,7 @@ """ Utilities module specific to code resources such as Lambda functions and Lambda layers """ + from typing import Any, Dict from samcli.hook_packages.terraform.hooks.prepare.resource_linking import _resolve_resource_attribute diff --git a/samcli/hook_packages/terraform/hooks/prepare/resources/internal.py b/samcli/hook_packages/terraform/hooks/prepare/resources/internal.py index ffbe11f1a0..4effa85973 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/resources/internal.py +++ b/samcli/hook_packages/terraform/hooks/prepare/resources/internal.py @@ -1,4 +1,5 @@ """Module containing logic specific to internal resources handling during the prepare hook execution""" + from samcli.hook_packages.terraform.hooks.prepare.types import ResourceProperties INTERNAL_PREFIX = "Internal::" diff --git a/samcli/hook_packages/terraform/hooks/prepare/resources/lambda_function.py b/samcli/hook_packages/terraform/hooks/prepare/resources/lambda_function.py index 46460904b0..1738119fe9 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/resources/lambda_function.py +++ b/samcli/hook_packages/terraform/hooks/prepare/resources/lambda_function.py @@ -1,4 +1,5 @@ """Module containing logic specific to Lambda function resource handling during the prepare hook execution""" + from typing import Dict, List, Tuple from samcli.hook_packages.terraform.hooks.prepare.resources.code_resource_utils import ( diff --git a/samcli/hook_packages/terraform/hooks/prepare/resources/resource_properties.py b/samcli/hook_packages/terraform/hooks/prepare/resources/resource_properties.py index 76931dd22b..8fbf58149b 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/resources/resource_properties.py +++ b/samcli/hook_packages/terraform/hooks/prepare/resources/resource_properties.py @@ -1,4 +1,5 @@ """Module for getting the resource property mappings for various resource types""" + from typing import Dict from samcli.hook_packages.terraform.hooks.prepare.constants import ( diff --git a/samcli/hook_packages/terraform/hooks/prepare/translate.py b/samcli/hook_packages/terraform/hooks/prepare/translate.py index bd32102eb2..e71540bcda 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/translate.py +++ b/samcli/hook_packages/terraform/hooks/prepare/translate.py @@ -3,6 +3,7 @@ This method contains the logic required to translate the `terraform show` JSON output into a Cloudformation template """ + import hashlib import logging from typing import Any, Dict, Iterator, List, Tuple, Type, Union diff --git a/samcli/hook_packages/terraform/hooks/prepare/types.py b/samcli/hook_packages/terraform/hooks/prepare/types.py index 361ddc95fd..30e27085eb 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/types.py +++ b/samcli/hook_packages/terraform/hooks/prepare/types.py @@ -1,4 +1,5 @@ """ Contains the data types used in the TF prepare hook""" + from abc import ABC from copy import deepcopy from dataclasses import dataclass diff --git a/samcli/hook_packages/terraform/hooks/prepare/utilities.py b/samcli/hook_packages/terraform/hooks/prepare/utilities.py index c0261b95b8..c58104eaa7 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/utilities.py +++ b/samcli/hook_packages/terraform/hooks/prepare/utilities.py @@ -1,4 +1,5 @@ """ Maintain the utilities functions used in prepare hook """ + from samcli.hook_packages.terraform.hooks.prepare.constants import COMPILED_REGULAR_EXPRESSION diff --git a/samcli/hook_packages/terraform/lib/utils.py b/samcli/hook_packages/terraform/lib/utils.py index 888c9f809b..8fae5f9d96 100644 --- a/samcli/hook_packages/terraform/lib/utils.py +++ b/samcli/hook_packages/terraform/lib/utils.py @@ -1,4 +1,5 @@ """Terraform utilities""" + import hashlib from typing import Any, Dict, List, Union diff --git a/samcli/hook_packages/terraform/main.py b/samcli/hook_packages/terraform/main.py index 9f402500f3..e66309abf0 100644 --- a/samcli/hook_packages/terraform/main.py +++ b/samcli/hook_packages/terraform/main.py @@ -1,6 +1,7 @@ """ Module for Terraform hook entry points """ + from .hooks.prepare.hook import prepare as prepare_hook diff --git a/samcli/lib/bootstrap/companion_stack/companion_stack_builder.py b/samcli/lib/bootstrap/companion_stack/companion_stack_builder.py index 9d4f6fc705..a8d21c3f0a 100644 --- a/samcli/lib/bootstrap/companion_stack/companion_stack_builder.py +++ b/samcli/lib/bootstrap/companion_stack/companion_stack_builder.py @@ -1,6 +1,7 @@ """ Companion stack template builder """ + from typing import Dict, cast from samcli.lib.bootstrap.companion_stack.data_types import CompanionStack, ECRRepo diff --git a/samcli/lib/bootstrap/companion_stack/companion_stack_manager.py b/samcli/lib/bootstrap/companion_stack/companion_stack_manager.py index 8f183beb40..4e647793b7 100644 --- a/samcli/lib/bootstrap/companion_stack/companion_stack_manager.py +++ b/samcli/lib/bootstrap/companion_stack/companion_stack_manager.py @@ -1,6 +1,7 @@ """ Companion stack manager """ + import logging from typing import Dict, List, Optional diff --git a/samcli/lib/bootstrap/companion_stack/data_types.py b/samcli/lib/bootstrap/companion_stack/data_types.py index 8cce26ba30..2725804220 100644 --- a/samcli/lib/bootstrap/companion_stack/data_types.py +++ b/samcli/lib/bootstrap/companion_stack/data_types.py @@ -1,6 +1,7 @@ """ Date type classes for companion stacks """ + import posixpath import re from typing import Optional diff --git a/samcli/lib/bootstrap/nested_stack/nested_stack_builder.py b/samcli/lib/bootstrap/nested_stack/nested_stack_builder.py index 4ed9cbe1d3..36a2177e1f 100644 --- a/samcli/lib/bootstrap/nested_stack/nested_stack_builder.py +++ b/samcli/lib/bootstrap/nested_stack/nested_stack_builder.py @@ -1,6 +1,7 @@ """ StackBuilder implementation for nested stack """ + import re from typing import cast diff --git a/samcli/lib/bootstrap/nested_stack/nested_stack_manager.py b/samcli/lib/bootstrap/nested_stack/nested_stack_manager.py index b0d6faed98..ee2af65fa8 100644 --- a/samcli/lib/bootstrap/nested_stack/nested_stack_manager.py +++ b/samcli/lib/bootstrap/nested_stack/nested_stack_manager.py @@ -1,6 +1,7 @@ """ nested stack manager to generate nested stack information and update original template with it """ + import logging import os import shutil diff --git a/samcli/lib/bootstrap/stack_builder.py b/samcli/lib/bootstrap/stack_builder.py index 0654dd011f..9e680f8fa2 100644 --- a/samcli/lib/bootstrap/stack_builder.py +++ b/samcli/lib/bootstrap/stack_builder.py @@ -1,6 +1,7 @@ """ Abstract definitions for stack builder """ + import json from abc import ABC from copy import deepcopy diff --git a/samcli/lib/build/app_builder.py b/samcli/lib/build/app_builder.py index 0e49b7b285..6c8b0f02f1 100644 --- a/samcli/lib/build/app_builder.py +++ b/samcli/lib/build/app_builder.py @@ -1,6 +1,7 @@ """ Builds the application """ + import os import io import json diff --git a/samcli/lib/build/build_strategy.py b/samcli/lib/build/build_strategy.py index 7031e26b33..5fae26e79d 100644 --- a/samcli/lib/build/build_strategy.py +++ b/samcli/lib/build/build_strategy.py @@ -1,6 +1,7 @@ """ Keeps implementation of different build strategies """ + import hashlib import logging import os.path diff --git a/samcli/lib/build/bundler.py b/samcli/lib/build/bundler.py index ba23158d39..797171391f 100644 --- a/samcli/lib/build/bundler.py +++ b/samcli/lib/build/bundler.py @@ -1,6 +1,7 @@ """ Handles bundler properties as needed to modify the build process """ + import logging from copy import deepcopy from pathlib import Path, PosixPath diff --git a/samcli/lib/build/constants.py b/samcli/lib/build/constants.py index c7c4a3b94d..3f15a06dc7 100644 --- a/samcli/lib/build/constants.py +++ b/samcli/lib/build/constants.py @@ -1,6 +1,7 @@ """ build constants """ + from typing import Set DEPRECATED_RUNTIMES: Set[str] = { diff --git a/samcli/lib/build/dependency_hash_generator.py b/samcli/lib/build/dependency_hash_generator.py index bbf9f1bec0..635618f91d 100644 --- a/samcli/lib/build/dependency_hash_generator.py +++ b/samcli/lib/build/dependency_hash_generator.py @@ -1,4 +1,5 @@ """Utility Class for Getting Function or Layer Manifest Dependency Hashes""" + import pathlib from typing import Any, Optional diff --git a/samcli/lib/build/exceptions.py b/samcli/lib/build/exceptions.py index 2d33f367df..e1f4ff50fc 100644 --- a/samcli/lib/build/exceptions.py +++ b/samcli/lib/build/exceptions.py @@ -2,7 +2,6 @@ Build Related Exceptions. """ - from samcli.commands.exceptions import UserException diff --git a/samcli/lib/build/utils.py b/samcli/lib/build/utils.py index c4941f369a..45ef2c4672 100644 --- a/samcli/lib/build/utils.py +++ b/samcli/lib/build/utils.py @@ -1,6 +1,7 @@ """ build utilities """ + import logging from typing import Union, Dict, Optional diff --git a/samcli/lib/cli_validation/image_repository_validation.py b/samcli/lib/cli_validation/image_repository_validation.py index 8d26ff558e..67f4ea965e 100644 --- a/samcli/lib/cli_validation/image_repository_validation.py +++ b/samcli/lib/cli_validation/image_repository_validation.py @@ -2,6 +2,7 @@ Image Repository Option Validation. This is to be run last after all CLI options have been processed. """ + import click from samcli.commands._utils.option_validator import Validator diff --git a/samcli/lib/cli_validation/remote_invoke_options_validations.py b/samcli/lib/cli_validation/remote_invoke_options_validations.py index bed1591f15..4b645190ce 100644 --- a/samcli/lib/cli_validation/remote_invoke_options_validations.py +++ b/samcli/lib/cli_validation/remote_invoke_options_validations.py @@ -1,6 +1,7 @@ """ This file contains validations remote invoke options """ + import logging import sys from functools import wraps diff --git a/samcli/lib/config/exceptions.py b/samcli/lib/config/exceptions.py index 4b3336ed8d..aabcff5743 100644 --- a/samcli/lib/config/exceptions.py +++ b/samcli/lib/config/exceptions.py @@ -2,7 +2,6 @@ Exceptions to be used by samconfig.py """ - from samcli.commands.exceptions import UserException diff --git a/samcli/lib/config/file_manager.py b/samcli/lib/config/file_manager.py index 0629ace318..607e4f727f 100644 --- a/samcli/lib/config/file_manager.py +++ b/samcli/lib/config/file_manager.py @@ -2,7 +2,6 @@ Class to represent the parsing of different file types into Python objects. """ - import json import logging from abc import ABC, abstractmethod diff --git a/samcli/lib/cookiecutter/interactive_flow.py b/samcli/lib/cookiecutter/interactive_flow.py index 2c31ac1287..67e1256d1c 100644 --- a/samcli/lib/cookiecutter/interactive_flow.py +++ b/samcli/lib/cookiecutter/interactive_flow.py @@ -1,4 +1,5 @@ """A flow of questions to be asked to the user in an interactive way.""" + from typing import Any, Dict, List, Optional, Tuple import click diff --git a/samcli/lib/cookiecutter/interactive_flow_creator.py b/samcli/lib/cookiecutter/interactive_flow_creator.py index 370e4a3831..8a7b9c5bae 100644 --- a/samcli/lib/cookiecutter/interactive_flow_creator.py +++ b/samcli/lib/cookiecutter/interactive_flow_creator.py @@ -1,4 +1,5 @@ """ This module parses a json/yaml file that defines a flow of questions to fulfill the cookiecutter context""" + from typing import Dict, Optional, Tuple import yaml diff --git a/samcli/lib/cookiecutter/plugin.py b/samcli/lib/cookiecutter/plugin.py index 09cc7b113c..a8a7cb4cad 100644 --- a/samcli/lib/cookiecutter/plugin.py +++ b/samcli/lib/cookiecutter/plugin.py @@ -1,6 +1,7 @@ """ Plugins are sub-sets of templates, it encapsulate common behavior of different templates and plugged to each of them """ + from typing import NamedTuple from .interactive_flow import InteractiveFlow diff --git a/samcli/lib/cookiecutter/processor.py b/samcli/lib/cookiecutter/processor.py index 4f34df06f8..bab7f88770 100644 --- a/samcli/lib/cookiecutter/processor.py +++ b/samcli/lib/cookiecutter/processor.py @@ -1,4 +1,5 @@ """ Define a processor to process the cookiecutter context before/after generating a cookiecutter project""" + from abc import ABC, abstractmethod from typing import Dict diff --git a/samcli/lib/cookiecutter/question.py b/samcli/lib/cookiecutter/question.py index 843d9dfc11..76412307f4 100644 --- a/samcli/lib/cookiecutter/question.py +++ b/samcli/lib/cookiecutter/question.py @@ -1,4 +1,5 @@ """ This module represents the questions to ask to the user to fulfill the cookiecutter context. """ + from abc import ABC, abstractmethod from enum import Enum from typing import Any, Dict, List, Optional, Type, Union diff --git a/samcli/lib/cookiecutter/template.py b/samcli/lib/cookiecutter/template.py index ddce7b6b82..9ff2a279b9 100644 --- a/samcli/lib/cookiecutter/template.py +++ b/samcli/lib/cookiecutter/template.py @@ -2,6 +2,7 @@ This is the core module of the cookiecutter workflow, it defines how to create a template, prompt the user for values of the context and how to generate a project from the given template and provided context """ + import logging from typing import Dict, List, Optional diff --git a/samcli/lib/deploy/deployer.py b/samcli/lib/deploy/deployer.py index 0500a41901..effe608001 100644 --- a/samcli/lib/deploy/deployer.py +++ b/samcli/lib/deploy/deployer.py @@ -258,9 +258,9 @@ def describe_changeset(self, change_set_id, stack_name, **kwargs): { "LogicalResourceId": resource_props.get("LogicalResourceId"), "ResourceType": resource_props.get("ResourceType"), - "Replacement": "N/A" - if resource_props.get("Replacement") is None - else resource_props.get("Replacement"), + "Replacement": ( + "N/A" if resource_props.get("Replacement") is None else resource_props.get("Replacement") + ), } ) diff --git a/samcli/lib/docker/log_streamer.py b/samcli/lib/docker/log_streamer.py index 3bb437781a..c4aacfd09d 100644 --- a/samcli/lib/docker/log_streamer.py +++ b/samcli/lib/docker/log_streamer.py @@ -1,6 +1,7 @@ """ Log streaming utilities when streaming logs from Docker """ + import os from typing import Dict diff --git a/samcli/lib/docs/browser_configuration.py b/samcli/lib/docs/browser_configuration.py index f966ee69ec..f3d00f0e17 100644 --- a/samcli/lib/docs/browser_configuration.py +++ b/samcli/lib/docs/browser_configuration.py @@ -1,6 +1,7 @@ """ Library housing logic for handling web browsers """ + import logging import webbrowser from enum import Enum diff --git a/samcli/lib/docs/documentation.py b/samcli/lib/docs/documentation.py index a78556238c..fc5ae45a4f 100644 --- a/samcli/lib/docs/documentation.py +++ b/samcli/lib/docs/documentation.py @@ -1,6 +1,7 @@ """ Library housing the logic for handling AWS SAM CLI documentation pages """ + import json import logging from pathlib import Path diff --git a/samcli/lib/generated_sample_events/events.py b/samcli/lib/generated_sample_events/events.py index 00ee4a38f0..5d8dd490ff 100644 --- a/samcli/lib/generated_sample_events/events.py +++ b/samcli/lib/generated_sample_events/events.py @@ -21,7 +21,6 @@ class Events: - """ Events library class that loads and customizes event json files diff --git a/samcli/lib/hook/exceptions.py b/samcli/lib/hook/exceptions.py index a4b162826b..c5867a7ed1 100644 --- a/samcli/lib/hook/exceptions.py +++ b/samcli/lib/hook/exceptions.py @@ -1,4 +1,5 @@ """Hooks Exceptions""" + from samcli.commands.exceptions import UserException diff --git a/samcli/lib/hook/hook_config.py b/samcli/lib/hook/hook_config.py index 92908642de..7f53c18411 100644 --- a/samcli/lib/hook/hook_config.py +++ b/samcli/lib/hook/hook_config.py @@ -1,4 +1,5 @@ """Hook Package Config""" + import json from pathlib import Path from typing import Dict, NamedTuple, Optional, cast diff --git a/samcli/lib/hook/hook_wrapper.py b/samcli/lib/hook/hook_wrapper.py index 9580be5a00..87bbdbb31b 100644 --- a/samcli/lib/hook/hook_wrapper.py +++ b/samcli/lib/hook/hook_wrapper.py @@ -1,6 +1,7 @@ """ Hooks Wrapper Class """ + import importlib import logging from pathlib import Path diff --git a/samcli/lib/iac/cdk/cdk_iac.py b/samcli/lib/iac/cdk/cdk_iac.py index 700c1ef3c3..bc79acdb15 100644 --- a/samcli/lib/iac/cdk/cdk_iac.py +++ b/samcli/lib/iac/cdk/cdk_iac.py @@ -1,6 +1,7 @@ """ Provide a CDK implementation of IaCPluginInterface """ + from typing import List from samcli.lib.iac.plugins_interfaces import IaCPluginInterface, LookupPath, SamCliProject, Stack diff --git a/samcli/lib/iac/cfn/cfn_iac.py b/samcli/lib/iac/cfn/cfn_iac.py index 7617af2f92..7676fa1964 100644 --- a/samcli/lib/iac/cfn/cfn_iac.py +++ b/samcli/lib/iac/cfn/cfn_iac.py @@ -1,6 +1,7 @@ """ Provide a CFN implementation of IaCPluginInterface """ + import logging import os from typing import List, Optional diff --git a/samcli/lib/iac/constants.py b/samcli/lib/iac/constants.py index c3c992aa25..dead7f559c 100644 --- a/samcli/lib/iac/constants.py +++ b/samcli/lib/iac/constants.py @@ -1,5 +1,6 @@ """ General IaC constants """ + PARAMETER_OVERRIDES = "parameter_overrides" GLOBAL_PARAMETER_OVERRIDES = "global_parameter_overrides" diff --git a/samcli/lib/iac/exceptions.py b/samcli/lib/iac/exceptions.py index ed84517f6e..2d1872cb60 100644 --- a/samcli/lib/iac/exceptions.py +++ b/samcli/lib/iac/exceptions.py @@ -1,6 +1,7 @@ """ IaC Exceptions """ + from typing import Optional from samcli.commands.exceptions import UserException diff --git a/samcli/lib/iac/iac_factory.py b/samcli/lib/iac/iac_factory.py index 766925e797..3b629b4abc 100644 --- a/samcli/lib/iac/iac_factory.py +++ b/samcli/lib/iac/iac_factory.py @@ -1,6 +1,7 @@ """ Provide a factory class for IaC project creation """ + import fnmatch import os diff --git a/samcli/lib/init/__init__.py b/samcli/lib/init/__init__.py index e0b8ff0e5b..241076bc05 100644 --- a/samcli/lib/init/__init__.py +++ b/samcli/lib/init/__init__.py @@ -1,6 +1,7 @@ """ Init module to scaffold a project app from a template """ + import itertools import logging import platform diff --git a/samcli/lib/init/default_samconfig.py b/samcli/lib/init/default_samconfig.py index c45d5fea77..c075761b20 100644 --- a/samcli/lib/init/default_samconfig.py +++ b/samcli/lib/init/default_samconfig.py @@ -1,6 +1,7 @@ """ Module for creating default samconfig.toml files after initialize a sample app """ + from dataclasses import dataclass from enum import Enum from typing import Any, List diff --git a/samcli/lib/init/template_modifiers/application_insights_template_modifier.py b/samcli/lib/init/template_modifiers/application_insights_template_modifier.py index 4a44784307..42139026ad 100644 --- a/samcli/lib/init/template_modifiers/application_insights_template_modifier.py +++ b/samcli/lib/init/template_modifiers/application_insights_template_modifier.py @@ -1,6 +1,7 @@ """ Class used to parse and update template when application-insights is enabled """ + import logging from typing import Any diff --git a/samcli/lib/init/template_modifiers/cli_template_modifier.py b/samcli/lib/init/template_modifiers/cli_template_modifier.py index 848defc7b7..fe21a1f39b 100644 --- a/samcli/lib/init/template_modifiers/cli_template_modifier.py +++ b/samcli/lib/init/template_modifiers/cli_template_modifier.py @@ -1,6 +1,7 @@ """ Class used to parse and update template with new field """ + import logging from abc import abstractmethod from copy import deepcopy diff --git a/samcli/lib/init/template_modifiers/structured_logging_template_modifier.py b/samcli/lib/init/template_modifiers/structured_logging_template_modifier.py index 798ce9cd18..7221ae8a33 100644 --- a/samcli/lib/init/template_modifiers/structured_logging_template_modifier.py +++ b/samcli/lib/init/template_modifiers/structured_logging_template_modifier.py @@ -1,6 +1,7 @@ """ Class used to parse and update template when structured logging is enabled """ + import logging from typing import Any diff --git a/samcli/lib/init/template_modifiers/xray_tracing_template_modifier.py b/samcli/lib/init/template_modifiers/xray_tracing_template_modifier.py index e0c0a445d7..961cf07700 100644 --- a/samcli/lib/init/template_modifiers/xray_tracing_template_modifier.py +++ b/samcli/lib/init/template_modifiers/xray_tracing_template_modifier.py @@ -1,6 +1,7 @@ """ Class used to parse and update template when tracing is enabled """ + import logging from typing import Any diff --git a/samcli/lib/intrinsic_resolver/intrinsic_property_resolver.py b/samcli/lib/intrinsic_resolver/intrinsic_property_resolver.py index 3fdd1c2e58..1fee887de7 100644 --- a/samcli/lib/intrinsic_resolver/intrinsic_property_resolver.py +++ b/samcli/lib/intrinsic_resolver/intrinsic_property_resolver.py @@ -1,6 +1,7 @@ """ Process and simplifies CloudFormation intrinsic properties such as FN::* and Ref """ + import base64 import copy import logging diff --git a/samcli/lib/intrinsic_resolver/intrinsics_symbol_table.py b/samcli/lib/intrinsic_resolver/intrinsics_symbol_table.py index e5d704214e..feefb46c03 100644 --- a/samcli/lib/intrinsic_resolver/intrinsics_symbol_table.py +++ b/samcli/lib/intrinsic_resolver/intrinsics_symbol_table.py @@ -1,6 +1,7 @@ """ The symbol table that is used in IntrinsicResolver in order to resolve runtime attributes """ + import logging import os diff --git a/samcli/lib/intrinsic_resolver/invalid_intrinsic_validation.py b/samcli/lib/intrinsic_resolver/invalid_intrinsic_validation.py index bc11644efb..a8e6e6f6e8 100644 --- a/samcli/lib/intrinsic_resolver/invalid_intrinsic_validation.py +++ b/samcli/lib/intrinsic_resolver/invalid_intrinsic_validation.py @@ -1,6 +1,7 @@ """ A list of helper functions that cleanup the processing in IntrinsicResolver and IntrinsicSymbolTable """ + from samcli.lib.intrinsic_resolver.invalid_intrinsic_exception import InvalidIntrinsicException diff --git a/samcli/lib/list/data_to_json_mapper.py b/samcli/lib/list/data_to_json_mapper.py index d99f5dc04f..81d44ca493 100644 --- a/samcli/lib/list/data_to_json_mapper.py +++ b/samcli/lib/list/data_to_json_mapper.py @@ -1,6 +1,7 @@ """ Implementation of the data to json mapper """ + import json from typing import Dict diff --git a/samcli/lib/list/endpoints/endpoints_def.py b/samcli/lib/list/endpoints/endpoints_def.py index 7bd29dea77..f44b75b6e6 100644 --- a/samcli/lib/list/endpoints/endpoints_def.py +++ b/samcli/lib/list/endpoints/endpoints_def.py @@ -1,6 +1,7 @@ """ The container for Endpoints """ + from dataclasses import dataclass from typing import Any diff --git a/samcli/lib/list/endpoints/endpoints_producer.py b/samcli/lib/list/endpoints/endpoints_producer.py index b708944e31..70c82687ce 100644 --- a/samcli/lib/list/endpoints/endpoints_producer.py +++ b/samcli/lib/list/endpoints/endpoints_producer.py @@ -1,6 +1,7 @@ """ The producer for the 'sam list endpoints' command """ + import dataclasses import json import logging @@ -468,9 +469,9 @@ def get_response_domain_dict(response: Dict[Any, Any]) -> Dict[str, str]: resource.get(RESOURCE_TYPE, "") == AWS_APIGATEWAY_DOMAIN_NAME or resource.get(RESOURCE_TYPE, "") == AWS_APIGATEWAY_V2_DOMAIN_NAME ): - response_domain_dict[ - resource.get(LOGICAL_RESOURCE_ID, "") - ] = f'https://{resource.get(PHYSICAL_RESOURCE_ID, "")}' + response_domain_dict[resource.get(LOGICAL_RESOURCE_ID, "")] = ( + f'https://{resource.get(PHYSICAL_RESOURCE_ID, "")}' + ) return response_domain_dict diff --git a/samcli/lib/list/endpoints/endpoints_to_table_mapper.py b/samcli/lib/list/endpoints/endpoints_to_table_mapper.py index 6efe234edb..6521616f59 100644 --- a/samcli/lib/list/endpoints/endpoints_to_table_mapper.py +++ b/samcli/lib/list/endpoints/endpoints_to_table_mapper.py @@ -1,6 +1,7 @@ """ Implementation of the endpoints to table mapper """ + from collections import OrderedDict from typing import Any, Dict diff --git a/samcli/lib/list/list_interfaces.py b/samcli/lib/list/list_interfaces.py index 91b8b559ca..ed6d7c4598 100644 --- a/samcli/lib/list/list_interfaces.py +++ b/samcli/lib/list/list_interfaces.py @@ -1,6 +1,7 @@ """ Interface for MapperConsumerFactory, Producer, Mapper, ListInfoPullerConsumer """ + from abc import ABC, abstractmethod from enum import Enum from typing import Generic, TypeVar diff --git a/samcli/lib/list/mapper_consumer_container.py b/samcli/lib/list/mapper_consumer_container.py index 80360d7a16..babf6d81d4 100644 --- a/samcli/lib/list/mapper_consumer_container.py +++ b/samcli/lib/list/mapper_consumer_container.py @@ -1,6 +1,7 @@ """ Container for a mapper and a consumer """ + from dataclasses import dataclass from samcli.lib.list.list_interfaces import ListInfoPullerConsumer, Mapper diff --git a/samcli/lib/list/mapper_consumer_factory.py b/samcli/lib/list/mapper_consumer_factory.py index 84b9d1c02e..bdf6578ea1 100644 --- a/samcli/lib/list/mapper_consumer_factory.py +++ b/samcli/lib/list/mapper_consumer_factory.py @@ -1,6 +1,7 @@ """ The factory for returning the appropriate mapper and consumer """ + from samcli.commands.list.json_consumer import StringConsumerJsonOutput from samcli.commands.list.table_consumer import StringConsumerTableOutput from samcli.lib.list.data_to_json_mapper import DataToJsonMapper diff --git a/samcli/lib/list/resources/resource_mapping_producer.py b/samcli/lib/list/resources/resource_mapping_producer.py index 96b7e7c56c..562f145f9a 100644 --- a/samcli/lib/list/resources/resource_mapping_producer.py +++ b/samcli/lib/list/resources/resource_mapping_producer.py @@ -1,6 +1,7 @@ """ The producer for the 'sam list resources' command """ + import dataclasses import logging from typing import Any, Dict diff --git a/samcli/lib/list/resources/resources_def.py b/samcli/lib/list/resources/resources_def.py index 37bebecbba..802ac4faf9 100644 --- a/samcli/lib/list/resources/resources_def.py +++ b/samcli/lib/list/resources/resources_def.py @@ -1,6 +1,7 @@ """ The container for Resources """ + from dataclasses import dataclass diff --git a/samcli/lib/list/resources/resources_to_table_mapper.py b/samcli/lib/list/resources/resources_to_table_mapper.py index ca87644ed7..d33757a66f 100644 --- a/samcli/lib/list/resources/resources_to_table_mapper.py +++ b/samcli/lib/list/resources/resources_to_table_mapper.py @@ -1,6 +1,7 @@ """ Implementation of the resources to table mapper """ + from collections import OrderedDict from typing import Any, Dict diff --git a/samcli/lib/list/stack_outputs/stack_output_to_table_mapper.py b/samcli/lib/list/stack_outputs/stack_output_to_table_mapper.py index 0be89deae6..68c8255526 100644 --- a/samcli/lib/list/stack_outputs/stack_output_to_table_mapper.py +++ b/samcli/lib/list/stack_outputs/stack_output_to_table_mapper.py @@ -1,6 +1,7 @@ """ Implementation of the stack output to table mapper """ + from collections import OrderedDict from typing import Any, Dict diff --git a/samcli/lib/list/stack_outputs/stack_outputs.py b/samcli/lib/list/stack_outputs/stack_outputs.py index 292da23b48..b0500afa0d 100644 --- a/samcli/lib/list/stack_outputs/stack_outputs.py +++ b/samcli/lib/list/stack_outputs/stack_outputs.py @@ -1,6 +1,7 @@ """ The container for stack outputs """ + from dataclasses import dataclass diff --git a/samcli/lib/list/stack_outputs/stack_outputs_producer.py b/samcli/lib/list/stack_outputs/stack_outputs_producer.py index dc8df62d8e..198664b628 100644 --- a/samcli/lib/list/stack_outputs/stack_outputs_producer.py +++ b/samcli/lib/list/stack_outputs/stack_outputs_producer.py @@ -1,6 +1,7 @@ """ The producer for the 'sam list stack-outputs' command """ + import dataclasses import logging from typing import Any, Optional diff --git a/samcli/lib/observability/cw_logs/cw_log_event.py b/samcli/lib/observability/cw_logs/cw_log_event.py index 49b9a4e889..1258cec9f1 100644 --- a/samcli/lib/observability/cw_logs/cw_log_event.py +++ b/samcli/lib/observability/cw_logs/cw_log_event.py @@ -1,6 +1,7 @@ """ CloudWatch log event type """ + from typing import Optional from samcli.lib.observability.observability_info_puller import ObservabilityEvent diff --git a/samcli/lib/observability/cw_logs/cw_log_formatters.py b/samcli/lib/observability/cw_logs/cw_log_formatters.py index 63b2ffd983..e761bea5f5 100644 --- a/samcli/lib/observability/cw_logs/cw_log_formatters.py +++ b/samcli/lib/observability/cw_logs/cw_log_formatters.py @@ -1,6 +1,7 @@ """ Contains all mappers (formatters) for CloudWatch logs """ + import json import logging from json import JSONDecodeError diff --git a/samcli/lib/observability/cw_logs/cw_log_group_provider.py b/samcli/lib/observability/cw_logs/cw_log_group_provider.py index e920ee41a7..0bcb70328a 100644 --- a/samcli/lib/observability/cw_logs/cw_log_group_provider.py +++ b/samcli/lib/observability/cw_logs/cw_log_group_provider.py @@ -1,6 +1,7 @@ """ Discover & provide the log group name """ + import logging from typing import Optional diff --git a/samcli/lib/observability/cw_logs/cw_log_puller.py b/samcli/lib/observability/cw_logs/cw_log_puller.py index b2f8c885d1..409be8d3a5 100644 --- a/samcli/lib/observability/cw_logs/cw_log_puller.py +++ b/samcli/lib/observability/cw_logs/cw_log_puller.py @@ -1,6 +1,7 @@ """ CloudWatch log event puller implementation """ + import logging import time from datetime import datetime diff --git a/samcli/lib/observability/observability_info_puller.py b/samcli/lib/observability/observability_info_puller.py index d5990feae5..ef16041045 100644 --- a/samcli/lib/observability/observability_info_puller.py +++ b/samcli/lib/observability/observability_info_puller.py @@ -1,6 +1,7 @@ """ Interfaces and generic implementations for observability events (like CW logs) """ + import logging from abc import ABC, abstractmethod from datetime import datetime diff --git a/samcli/lib/observability/util.py b/samcli/lib/observability/util.py index d3996d6353..24b610b46a 100644 --- a/samcli/lib/observability/util.py +++ b/samcli/lib/observability/util.py @@ -1,6 +1,7 @@ """ Utility classes and methods for observability commands and functionality """ + from enum import Enum diff --git a/samcli/lib/observability/xray_traces/xray_event_mappers.py b/samcli/lib/observability/xray_traces/xray_event_mappers.py index bcd367dd97..224cb3bad6 100644 --- a/samcli/lib/observability/xray_traces/xray_event_mappers.py +++ b/samcli/lib/observability/xray_traces/xray_event_mappers.py @@ -1,6 +1,7 @@ """ Contains mapper implementations of XRay events """ + import json from copy import deepcopy from datetime import datetime diff --git a/samcli/lib/observability/xray_traces/xray_event_puller.py b/samcli/lib/observability/xray_traces/xray_event_puller.py index 506257e4d6..b012f98693 100644 --- a/samcli/lib/observability/xray_traces/xray_event_puller.py +++ b/samcli/lib/observability/xray_traces/xray_event_puller.py @@ -1,6 +1,7 @@ """ This file contains puller implementations for XRay """ + import logging import time from datetime import datetime diff --git a/samcli/lib/observability/xray_traces/xray_events.py b/samcli/lib/observability/xray_traces/xray_events.py index de610ca115..f39fcea5a0 100644 --- a/samcli/lib/observability/xray_traces/xray_events.py +++ b/samcli/lib/observability/xray_traces/xray_events.py @@ -1,6 +1,7 @@ """ Keeps XRay event definitions """ + import json import operator from typing import List, Optional diff --git a/samcli/lib/observability/xray_traces/xray_service_graph_event_puller.py b/samcli/lib/observability/xray_traces/xray_service_graph_event_puller.py index 9c3f0c3caf..019b27aa5c 100644 --- a/samcli/lib/observability/xray_traces/xray_service_graph_event_puller.py +++ b/samcli/lib/observability/xray_traces/xray_service_graph_event_puller.py @@ -1,6 +1,7 @@ """ This file contains puller implementations for XRay """ + import logging from datetime import datetime from typing import Any, Dict, List, Optional, Set, Union diff --git a/samcli/lib/package/ecr_uploader.py b/samcli/lib/package/ecr_uploader.py index 0393596b39..6414ccf071 100644 --- a/samcli/lib/package/ecr_uploader.py +++ b/samcli/lib/package/ecr_uploader.py @@ -1,6 +1,7 @@ """ Client for uploading packaged artifacts to ecr """ + import base64 import logging from io import StringIO diff --git a/samcli/lib/package/ecr_utils.py b/samcli/lib/package/ecr_utils.py index 2a068e55c0..c13be0f65f 100644 --- a/samcli/lib/package/ecr_utils.py +++ b/samcli/lib/package/ecr_utils.py @@ -1,6 +1,7 @@ """ ECR Packaging Utils """ + import re """ diff --git a/samcli/lib/package/image_utils.py b/samcli/lib/package/image_utils.py index b5a0a6bf83..fbff23ece0 100644 --- a/samcli/lib/package/image_utils.py +++ b/samcli/lib/package/image_utils.py @@ -1,6 +1,7 @@ """ Image artifacts based utilities """ + import docker from docker.errors import APIError, NullResource diff --git a/samcli/lib/package/local_files_utils.py b/samcli/lib/package/local_files_utils.py index d6dc1aa148..e7a9bf68e6 100644 --- a/samcli/lib/package/local_files_utils.py +++ b/samcli/lib/package/local_files_utils.py @@ -1,6 +1,7 @@ """ Utilities for local files handling. """ + import os import tempfile import uuid diff --git a/samcli/lib/package/packageable_resources.py b/samcli/lib/package/packageable_resources.py index ca245715b5..d2986cc98d 100644 --- a/samcli/lib/package/packageable_resources.py +++ b/samcli/lib/package/packageable_resources.py @@ -1,6 +1,7 @@ """ Code for all Package-able resources """ + import logging import os import shutil diff --git a/samcli/lib/package/permissions.py b/samcli/lib/package/permissions.py index 24da0bdac5..47c987df0e 100644 --- a/samcli/lib/package/permissions.py +++ b/samcli/lib/package/permissions.py @@ -1,6 +1,7 @@ """ Classes which will change permissions on a ZipInfo object """ + import platform import zipfile diff --git a/samcli/lib/package/stream_cursor_utils.py b/samcli/lib/package/stream_cursor_utils.py index 924e431baa..5f31b3b772 100644 --- a/samcli/lib/package/stream_cursor_utils.py +++ b/samcli/lib/package/stream_cursor_utils.py @@ -1,6 +1,7 @@ """ Stream cursor utilities for moving cursor in the terminal. """ + import os import platform diff --git a/samcli/lib/package/utils.py b/samcli/lib/package/utils.py index d0a1ae9787..ef0405060a 100644 --- a/samcli/lib/package/utils.py +++ b/samcli/lib/package/utils.py @@ -1,6 +1,7 @@ """ Utilities involved in Packaging. """ + import contextlib import functools import logging diff --git a/samcli/lib/pipeline/bootstrap/resource.py b/samcli/lib/pipeline/bootstrap/resource.py index cb5eb000e3..8f4f451808 100644 --- a/samcli/lib/pipeline/bootstrap/resource.py +++ b/samcli/lib/pipeline/bootstrap/resource.py @@ -1,4 +1,5 @@ """ Represents AWS resource""" + from typing import Optional from samcli.lib.utils.arn_utils import ARNParts diff --git a/samcli/lib/pipeline/bootstrap/stage.py b/samcli/lib/pipeline/bootstrap/stage.py index 06ab4fa6dc..7bca9dc315 100644 --- a/samcli/lib/pipeline/bootstrap/stage.py +++ b/samcli/lib/pipeline/bootstrap/stage.py @@ -1,4 +1,5 @@ """ Application Environment """ + import hashlib import json import os @@ -240,13 +241,17 @@ def _get_non_user_provided_resources_msg(self) -> str: [] if self.pipeline_user.is_user_provided or self.use_oidc_provider else [self.pipeline_user.comment], [] if not self.use_oidc_provider else [self.oidc_provider.comment], [] if self.pipeline_execution_role.is_user_provided else [self.pipeline_execution_role.comment], - [] - if self.cloudformation_execution_role.is_user_provided - else [self.cloudformation_execution_role.comment], + ( + [] + if self.cloudformation_execution_role.is_user_provided + else [self.cloudformation_execution_role.comment] + ), [] if self.artifacts_bucket.is_user_provided else [self.artifacts_bucket.comment], - [] - if self.image_repository.is_user_provided or not self.create_image_repository - else [self.image_repository.comment], + ( + [] + if self.image_repository.is_user_provided or not self.create_image_repository + else [self.image_repository.comment] + ), ] ) return "\n".join([f"\t- {comment}" for comment in resource_comments]) diff --git a/samcli/lib/providers/cfn_api_provider.py b/samcli/lib/providers/cfn_api_provider.py index b8f9e6f28c..f0a46cb74e 100644 --- a/samcli/lib/providers/cfn_api_provider.py +++ b/samcli/lib/providers/cfn_api_provider.py @@ -1,4 +1,5 @@ """Parses SAM given a template""" + import logging from typing import Any, Dict, List, Optional, Tuple, cast diff --git a/samcli/lib/providers/cfn_base_api_provider.py b/samcli/lib/providers/cfn_base_api_provider.py index 646bff37ab..bd336df701 100644 --- a/samcli/lib/providers/cfn_base_api_provider.py +++ b/samcli/lib/providers/cfn_base_api_provider.py @@ -1,4 +1,5 @@ """Class that parses the CloudFormation Api Template""" + import logging from typing import Any, Dict, List, Optional, Type, Union diff --git a/samcli/lib/providers/provider.py b/samcli/lib/providers/provider.py index e0d3183c15..d14f3fa4b0 100644 --- a/samcli/lib/providers/provider.py +++ b/samcli/lib/providers/provider.py @@ -2,6 +2,7 @@ A provider class that can parse and return Lambda Functions from a variety of sources. A SAM template is one such source """ + import hashlib import logging import os diff --git a/samcli/lib/providers/sam_function_provider.py b/samcli/lib/providers/sam_function_provider.py index cfed427ce0..da0c64eaca 100644 --- a/samcli/lib/providers/sam_function_provider.py +++ b/samcli/lib/providers/sam_function_provider.py @@ -1,6 +1,7 @@ """ Class that provides functions from a given SAM template """ + import logging from typing import Any, Dict, Iterator, List, Optional, cast diff --git a/samcli/lib/providers/sam_layer_provider.py b/samcli/lib/providers/sam_layer_provider.py index 44d68fafbb..ecd642f751 100644 --- a/samcli/lib/providers/sam_layer_provider.py +++ b/samcli/lib/providers/sam_layer_provider.py @@ -1,6 +1,7 @@ """ Class that provides layers from a given SAM template """ + import logging from typing import Dict, List, Optional diff --git a/samcli/lib/providers/sam_stack_provider.py b/samcli/lib/providers/sam_stack_provider.py index f174619886..0f9b174f95 100644 --- a/samcli/lib/providers/sam_stack_provider.py +++ b/samcli/lib/providers/sam_stack_provider.py @@ -1,6 +1,7 @@ """ Class that provides all nested stacks from a given SAM template """ + import logging import os from typing import Dict, Iterator, List, Optional, Tuple, Union, cast diff --git a/samcli/lib/remote_invoke/kinesis_invoke_executors.py b/samcli/lib/remote_invoke/kinesis_invoke_executors.py index ad020bd1ef..0c34c457e4 100644 --- a/samcli/lib/remote_invoke/kinesis_invoke_executors.py +++ b/samcli/lib/remote_invoke/kinesis_invoke_executors.py @@ -1,6 +1,7 @@ """ Remote invoke executor implementation for Kinesis streams """ + import logging import uuid from dataclasses import asdict, dataclass diff --git a/samcli/lib/remote_invoke/lambda_invoke_executors.py b/samcli/lib/remote_invoke/lambda_invoke_executors.py index 507999210e..423a604d3e 100644 --- a/samcli/lib/remote_invoke/lambda_invoke_executors.py +++ b/samcli/lib/remote_invoke/lambda_invoke_executors.py @@ -1,6 +1,7 @@ """ Remote invoke executor implementation for Lambda """ + import base64 import json import logging diff --git a/samcli/lib/remote_invoke/remote_invoke_executor_factory.py b/samcli/lib/remote_invoke/remote_invoke_executor_factory.py index 5d0daaa395..4b1d46e55b 100644 --- a/samcli/lib/remote_invoke/remote_invoke_executor_factory.py +++ b/samcli/lib/remote_invoke/remote_invoke_executor_factory.py @@ -1,6 +1,7 @@ """ Remote Invoke factory to instantiate remote invoker for given resource """ + import logging from typing import Any, Callable, Dict, Optional diff --git a/samcli/lib/remote_invoke/remote_invoke_executors.py b/samcli/lib/remote_invoke/remote_invoke_executors.py index f15899c02a..8dce0390c2 100644 --- a/samcli/lib/remote_invoke/remote_invoke_executors.py +++ b/samcli/lib/remote_invoke/remote_invoke_executors.py @@ -1,6 +1,7 @@ """ Abstract class definitions and generic implementations for remote invoke """ + import json import logging from abc import ABC, abstractmethod diff --git a/samcli/lib/remote_invoke/sqs_invoke_executors.py b/samcli/lib/remote_invoke/sqs_invoke_executors.py index b4454158fa..b92653f838 100644 --- a/samcli/lib/remote_invoke/sqs_invoke_executors.py +++ b/samcli/lib/remote_invoke/sqs_invoke_executors.py @@ -1,6 +1,7 @@ """ Remote invoke executor implementation for SQS """ + import json import logging from dataclasses import asdict, dataclass diff --git a/samcli/lib/remote_invoke/stepfunctions_invoke_executors.py b/samcli/lib/remote_invoke/stepfunctions_invoke_executors.py index f4d6a384c8..8a3a833214 100644 --- a/samcli/lib/remote_invoke/stepfunctions_invoke_executors.py +++ b/samcli/lib/remote_invoke/stepfunctions_invoke_executors.py @@ -1,6 +1,7 @@ """ Remote invoke executor implementation for Step Functions """ + import logging import time from datetime import datetime diff --git a/samcli/lib/sync/continuous_sync_flow_executor.py b/samcli/lib/sync/continuous_sync_flow_executor.py index 69a9f02de2..94932184af 100644 --- a/samcli/lib/sync/continuous_sync_flow_executor.py +++ b/samcli/lib/sync/continuous_sync_flow_executor.py @@ -1,4 +1,5 @@ """SyncFlowExecutor that will run continuously until stop is called.""" + import logging import time from concurrent.futures.thread import ThreadPoolExecutor diff --git a/samcli/lib/sync/exceptions.py b/samcli/lib/sync/exceptions.py index 89c2e529e5..c064e7a55e 100644 --- a/samcli/lib/sync/exceptions.py +++ b/samcli/lib/sync/exceptions.py @@ -1,4 +1,5 @@ """Exceptions related to sync functionalities""" + from typing import TYPE_CHECKING, Dict, Optional if TYPE_CHECKING: # pragma: no cover diff --git a/samcli/lib/sync/flows/alias_version_sync_flow.py b/samcli/lib/sync/flows/alias_version_sync_flow.py index be03d0bf4e..f3a270b69d 100644 --- a/samcli/lib/sync/flows/alias_version_sync_flow.py +++ b/samcli/lib/sync/flows/alias_version_sync_flow.py @@ -1,4 +1,5 @@ """SyncFlow for Lambda Function Alias and Version""" + import hashlib import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional diff --git a/samcli/lib/sync/flows/auto_dependency_layer_sync_flow.py b/samcli/lib/sync/flows/auto_dependency_layer_sync_flow.py index 8271d889de..002f51c228 100644 --- a/samcli/lib/sync/flows/auto_dependency_layer_sync_flow.py +++ b/samcli/lib/sync/flows/auto_dependency_layer_sync_flow.py @@ -1,6 +1,7 @@ """ Contains sync flow implementation for Auto Dependency Layer """ + import hashlib import logging import os diff --git a/samcli/lib/sync/flows/function_sync_flow.py b/samcli/lib/sync/flows/function_sync_flow.py index 55a04f5925..bf007eb71f 100644 --- a/samcli/lib/sync/flows/function_sync_flow.py +++ b/samcli/lib/sync/flows/function_sync_flow.py @@ -1,4 +1,5 @@ """Base SyncFlow for Lambda Function""" + import logging import time from abc import ABC diff --git a/samcli/lib/sync/flows/generic_api_sync_flow.py b/samcli/lib/sync/flows/generic_api_sync_flow.py index afd261dc88..b3452dad3c 100644 --- a/samcli/lib/sync/flows/generic_api_sync_flow.py +++ b/samcli/lib/sync/flows/generic_api_sync_flow.py @@ -1,4 +1,5 @@ """SyncFlow interface for HttpApi and RestApi""" + import hashlib import logging from abc import ABC diff --git a/samcli/lib/sync/flows/image_function_sync_flow.py b/samcli/lib/sync/flows/image_function_sync_flow.py index a2abb2a396..7cb9abda51 100644 --- a/samcli/lib/sync/flows/image_function_sync_flow.py +++ b/samcli/lib/sync/flows/image_function_sync_flow.py @@ -1,4 +1,5 @@ """SyncFlow for Image based Lambda Functions""" + import logging from contextlib import ExitStack from typing import TYPE_CHECKING, Any, Dict, List, Optional diff --git a/samcli/lib/sync/flows/layer_sync_flow.py b/samcli/lib/sync/flows/layer_sync_flow.py index e8ed77b074..a8e60f0c09 100644 --- a/samcli/lib/sync/flows/layer_sync_flow.py +++ b/samcli/lib/sync/flows/layer_sync_flow.py @@ -1,4 +1,5 @@ """SyncFlow for Layers""" + import base64 import hashlib import logging diff --git a/samcli/lib/sync/flows/rest_api_sync_flow.py b/samcli/lib/sync/flows/rest_api_sync_flow.py index 8bfc523460..419d4d3532 100644 --- a/samcli/lib/sync/flows/rest_api_sync_flow.py +++ b/samcli/lib/sync/flows/rest_api_sync_flow.py @@ -1,4 +1,5 @@ """SyncFlow for RestApi""" + import logging from typing import TYPE_CHECKING, Dict, List, Optional, Set, cast diff --git a/samcli/lib/sync/flows/stepfunctions_sync_flow.py b/samcli/lib/sync/flows/stepfunctions_sync_flow.py index 35e75d8dca..e1a394cb7f 100644 --- a/samcli/lib/sync/flows/stepfunctions_sync_flow.py +++ b/samcli/lib/sync/flows/stepfunctions_sync_flow.py @@ -1,4 +1,5 @@ """Base SyncFlow for StepFunctions""" + import hashlib import logging from pathlib import Path diff --git a/samcli/lib/sync/flows/zip_function_sync_flow.py b/samcli/lib/sync/flows/zip_function_sync_flow.py index 5e04685a08..4c051c1074 100644 --- a/samcli/lib/sync/flows/zip_function_sync_flow.py +++ b/samcli/lib/sync/flows/zip_function_sync_flow.py @@ -1,4 +1,5 @@ """SyncFlow for ZIP based Lambda Functions""" + import base64 import hashlib import logging diff --git a/samcli/lib/sync/infra_sync_executor.py b/samcli/lib/sync/infra_sync_executor.py index e5c48d44dd..30b0ef7cda 100644 --- a/samcli/lib/sync/infra_sync_executor.py +++ b/samcli/lib/sync/infra_sync_executor.py @@ -1,6 +1,7 @@ """ InfraSyncExecutor class which runs build, package and deploy contexts """ + import copy import logging import re @@ -337,9 +338,9 @@ def _auto_skip_infra_sync( nested_template_location, stack_resource_detail.get("StackResourceDetail", {}).get("PhysicalResourceId", ""), parameter_overrides={}, # Do not pass the same parameter overrides to the nested stack - nested_prefix=nested_prefix + resource_logical_id + "/" - if nested_prefix - else resource_logical_id + "/", + nested_prefix=( + nested_prefix + resource_logical_id + "/" if nested_prefix else resource_logical_id + "/" + ), ): return False diff --git a/samcli/lib/sync/sync_flow.py b/samcli/lib/sync/sync_flow.py index cf671fb5a8..1110297f22 100644 --- a/samcli/lib/sync/sync_flow.py +++ b/samcli/lib/sync/sync_flow.py @@ -1,4 +1,5 @@ """SyncFlow base class """ + import logging from abc import ABC, abstractmethod from enum import Enum diff --git a/samcli/lib/sync/sync_flow_executor.py b/samcli/lib/sync/sync_flow_executor.py index ae70be4ca9..db73abc528 100644 --- a/samcli/lib/sync/sync_flow_executor.py +++ b/samcli/lib/sync/sync_flow_executor.py @@ -1,4 +1,5 @@ """Executor for SyncFlows""" + import logging import time from concurrent.futures import Future, ThreadPoolExecutor diff --git a/samcli/lib/sync/sync_flow_factory.py b/samcli/lib/sync/sync_flow_factory.py index f9704bf95c..4fbdda54b3 100644 --- a/samcli/lib/sync/sync_flow_factory.py +++ b/samcli/lib/sync/sync_flow_factory.py @@ -1,4 +1,5 @@ """SyncFlow Factory for creating SyncFlows based on resource types""" + import logging from typing import TYPE_CHECKING, Callable, Dict, List, Optional, cast diff --git a/samcli/lib/sync/watch_manager.py b/samcli/lib/sync/watch_manager.py index ca3935878e..5f7cb17696 100644 --- a/samcli/lib/sync/watch_manager.py +++ b/samcli/lib/sync/watch_manager.py @@ -1,6 +1,7 @@ """ WatchManager for Sync Watch Logic """ + import logging import platform import threading diff --git a/samcli/lib/telemetry/metric.py b/samcli/lib/telemetry/metric.py index 681d2adc64..7f3127cf86 100644 --- a/samcli/lib/telemetry/metric.py +++ b/samcli/lib/telemetry/metric.py @@ -1,6 +1,7 @@ """ Provides methods to generate and send metrics """ + import logging import platform import uuid diff --git a/samcli/lib/telemetry/user_agent.py b/samcli/lib/telemetry/user_agent.py index 875a4d8788..c6b6e6bee9 100644 --- a/samcli/lib/telemetry/user_agent.py +++ b/samcli/lib/telemetry/user_agent.py @@ -1,6 +1,7 @@ """ Reads user agent information from environment and returns it for telemetry consumption """ + import os import re from typing import Optional diff --git a/samcli/lib/translate/sam_template_validator.py b/samcli/lib/translate/sam_template_validator.py index ff789925e0..5c2a9ed33d 100644 --- a/samcli/lib/translate/sam_template_validator.py +++ b/samcli/lib/translate/sam_template_validator.py @@ -1,6 +1,7 @@ """ Library for Validating Sam Templates """ + import functools import logging from typing import Dict, Optional, cast diff --git a/samcli/lib/utils/architecture.py b/samcli/lib/utils/architecture.py index 8c394d6229..25cff8888a 100644 --- a/samcli/lib/utils/architecture.py +++ b/samcli/lib/utils/architecture.py @@ -1,6 +1,7 @@ """ Architecture tools """ + from typing import TYPE_CHECKING, Dict, List, cast from samcli.commands.exceptions import UserException diff --git a/samcli/lib/utils/arn_utils.py b/samcli/lib/utils/arn_utils.py index 2df2aef9ea..be9fa24cbc 100644 --- a/samcli/lib/utils/arn_utils.py +++ b/samcli/lib/utils/arn_utils.py @@ -1,6 +1,7 @@ """ Module for utilities for ARN (Amazon Resource Names) """ + import re diff --git a/samcli/lib/utils/async_utils.py b/samcli/lib/utils/async_utils.py index 4652769d9e..82062d8487 100644 --- a/samcli/lib/utils/async_utils.py +++ b/samcli/lib/utils/async_utils.py @@ -1,6 +1,7 @@ """ Contains asyncio related methods and helpers """ + import logging from asyncio import AbstractEventLoop, gather, new_event_loop from concurrent.futures.thread import ThreadPoolExecutor diff --git a/samcli/lib/utils/boto_utils.py b/samcli/lib/utils/boto_utils.py index eab922f7dd..5cf91a331b 100644 --- a/samcli/lib/utils/boto_utils.py +++ b/samcli/lib/utils/boto_utils.py @@ -1,6 +1,7 @@ """ This module contains utility functions for boto3 library """ + from typing import Any, Optional from boto3 import Session @@ -28,17 +29,16 @@ def get_boto_config_with_user_agent(**kwargs) -> Config: """ gc = GlobalConfig() return Config( - user_agent_extra=f"aws-sam-cli/{__version__}/{gc.installation_id}" - if gc.telemetry_enabled - else f"aws-sam-cli/{__version__}", + user_agent_extra=( + f"aws-sam-cli/{__version__}/{gc.installation_id}" if gc.telemetry_enabled else f"aws-sam-cli/{__version__}" + ), **kwargs, ) # Type definition of following boto providers, which is equal to Callable[[str], Any] class BotoProviderType(Protocol): - def __call__(self, service_name: str) -> Any: - ... # pragma: no cover + def __call__(self, service_name: str) -> Any: ... # pragma: no cover def get_boto_client_provider_from_session_with_config(session: Session, **kwargs) -> BotoProviderType: diff --git a/samcli/lib/utils/cloudformation.py b/samcli/lib/utils/cloudformation.py index 04f49eef69..def89c6a11 100644 --- a/samcli/lib/utils/cloudformation.py +++ b/samcli/lib/utils/cloudformation.py @@ -1,6 +1,7 @@ """ This utility file contains methods to read information from certain CFN stack """ + import logging import posixpath from typing import Any, Dict, Iterable, Optional, Set diff --git a/samcli/lib/utils/code_trigger_factory.py b/samcli/lib/utils/code_trigger_factory.py index eb009d9aa5..9ff6b47b15 100644 --- a/samcli/lib/utils/code_trigger_factory.py +++ b/samcli/lib/utils/code_trigger_factory.py @@ -1,6 +1,7 @@ """ Factory for creating CodeResourceTriggers """ + import logging from pathlib import Path from typing import Any, Callable, Dict, List, Optional, cast diff --git a/samcli/lib/utils/defaults.py b/samcli/lib/utils/defaults.py index 4a07b113ac..37478b2a7a 100644 --- a/samcli/lib/utils/defaults.py +++ b/samcli/lib/utils/defaults.py @@ -1,6 +1,7 @@ """ Contains helpers for providing default values """ + from botocore.session import get_session diff --git a/samcli/lib/utils/definition_validator.py b/samcli/lib/utils/definition_validator.py index b267316de5..383fa80f1b 100644 --- a/samcli/lib/utils/definition_validator.py +++ b/samcli/lib/utils/definition_validator.py @@ -1,4 +1,5 @@ """DefinitionValidator for Validating YAML and JSON Files""" + import logging from pathlib import Path from typing import Any, Dict, Optional diff --git a/samcli/lib/utils/file_observer.py b/samcli/lib/utils/file_observer.py index a3ce40b440..230f47a7a6 100644 --- a/samcli/lib/utils/file_observer.py +++ b/samcli/lib/utils/file_observer.py @@ -1,6 +1,7 @@ """ Wraps watchdog to observe file system for any change. """ + import logging import platform import threading diff --git a/samcli/lib/utils/hash.py b/samcli/lib/utils/hash.py index b40a2ecb19..3c00eada96 100644 --- a/samcli/lib/utils/hash.py +++ b/samcli/lib/utils/hash.py @@ -1,6 +1,7 @@ """ Hash calculation utilities for files and directories. """ + import hashlib import os import sys diff --git a/samcli/lib/utils/lock_distributor.py b/samcli/lib/utils/lock_distributor.py index 2d4ad8dec0..141b2341b6 100644 --- a/samcli/lib/utils/lock_distributor.py +++ b/samcli/lib/utils/lock_distributor.py @@ -1,4 +1,5 @@ """LockDistributor for creating and managing a set of locks""" + import multiprocessing import multiprocessing.managers import threading diff --git a/samcli/lib/utils/managed_cloudformation_stack.py b/samcli/lib/utils/managed_cloudformation_stack.py index 83cee2e0a5..19d1bc2c50 100644 --- a/samcli/lib/utils/managed_cloudformation_stack.py +++ b/samcli/lib/utils/managed_cloudformation_stack.py @@ -1,6 +1,7 @@ """ Bootstrap's user's development environment by creating cloud resources required by SAM CLI """ + import logging from collections.abc import Collection from typing import Dict, List, Optional, Union, cast diff --git a/samcli/lib/utils/osutils.py b/samcli/lib/utils/osutils.py index a9a12bf88c..27430bfc62 100644 --- a/samcli/lib/utils/osutils.py +++ b/samcli/lib/utils/osutils.py @@ -1,6 +1,7 @@ """ Common OS utilities """ + import io import logging import os diff --git a/samcli/lib/utils/path_observer.py b/samcli/lib/utils/path_observer.py index c61cc07cf8..d22546d4d2 100644 --- a/samcli/lib/utils/path_observer.py +++ b/samcli/lib/utils/path_observer.py @@ -1,6 +1,7 @@ """ HandlerObserver and its helper classes. """ + import logging import re from dataclasses import dataclass diff --git a/samcli/lib/utils/path_utils.py b/samcli/lib/utils/path_utils.py index 694cd93e50..b47c621769 100644 --- a/samcli/lib/utils/path_utils.py +++ b/samcli/lib/utils/path_utils.py @@ -1,6 +1,7 @@ """ Common Path related utilities """ + from pathlib import PureWindowsPath diff --git a/samcli/lib/utils/preview_runtimes.py b/samcli/lib/utils/preview_runtimes.py index c17ae95cf8..9789ab5feb 100644 --- a/samcli/lib/utils/preview_runtimes.py +++ b/samcli/lib/utils/preview_runtimes.py @@ -2,6 +2,7 @@ Keeps list of preview runtimes, which can be used with sam build or sam local commands. But deployment of them would probably fail until their GA date """ + from typing import Set PREVIEW_RUNTIMES: Set[str] = set() diff --git a/samcli/lib/utils/profile.py b/samcli/lib/utils/profile.py index ab6edc5526..94c9fd6c2d 100644 --- a/samcli/lib/utils/profile.py +++ b/samcli/lib/utils/profile.py @@ -1,6 +1,7 @@ """ Module for aws profile related helpers """ + from typing import List from botocore.session import Session diff --git a/samcli/lib/utils/resource_trigger.py b/samcli/lib/utils/resource_trigger.py index 024a3b3caf..9f35aec33b 100644 --- a/samcli/lib/utils/resource_trigger.py +++ b/samcli/lib/utils/resource_trigger.py @@ -1,4 +1,5 @@ """ResourceTrigger Classes for Creating PathHandlers According to a Resource""" + import platform import re from abc import ABC, abstractmethod diff --git a/samcli/lib/utils/resource_type_based_factory.py b/samcli/lib/utils/resource_type_based_factory.py index 67a46f08af..01d8b9659c 100644 --- a/samcli/lib/utils/resource_type_based_factory.py +++ b/samcli/lib/utils/resource_type_based_factory.py @@ -1,4 +1,5 @@ """Base Factory Abstract Class for Creating Objects Specific to a Resource Type""" + import logging from abc import ABC, abstractmethod from typing import Callable, Dict, Generic, List, Optional, TypeVar diff --git a/samcli/lib/utils/retry.py b/samcli/lib/utils/retry.py index 2b8042d447..bfe8ccd4c2 100644 --- a/samcli/lib/utils/retry.py +++ b/samcli/lib/utils/retry.py @@ -1,6 +1,7 @@ """ Retry decorator to retry decorated function based on Exception with exponential backoff and number of attempts built-in. """ + import math import time from functools import wraps diff --git a/samcli/lib/utils/s3.py b/samcli/lib/utils/s3.py index e841fb236c..7be4c4ab0c 100644 --- a/samcli/lib/utils/s3.py +++ b/samcli/lib/utils/s3.py @@ -1,4 +1,5 @@ """Contains utility functions related to AWS S3 service""" + from typing import Any, Dict, Optional from urllib.parse import parse_qs, urlparse diff --git a/samcli/lib/utils/sam_logging.py b/samcli/lib/utils/sam_logging.py index 8ed2617ad9..bc02de61ef 100644 --- a/samcli/lib/utils/sam_logging.py +++ b/samcli/lib/utils/sam_logging.py @@ -1,6 +1,7 @@ """ Configures a logger """ + import logging import os import sys diff --git a/samcli/lib/utils/stream_writer.py b/samcli/lib/utils/stream_writer.py index dc2c2b9b5c..28c88d23da 100644 --- a/samcli/lib/utils/stream_writer.py +++ b/samcli/lib/utils/stream_writer.py @@ -1,6 +1,7 @@ """ This class acts like a wrapper around output streams to provide any flexibility with output we need """ + from io import BytesIO, TextIOWrapper from typing import Optional, TextIO, Union diff --git a/samcli/lib/utils/subprocess_utils.py b/samcli/lib/utils/subprocess_utils.py index 4539df19b6..284ea04d81 100644 --- a/samcli/lib/utils/subprocess_utils.py +++ b/samcli/lib/utils/subprocess_utils.py @@ -1,6 +1,7 @@ """ Utils for invoking subprocess calls """ + import logging import os import platform diff --git a/samcli/lib/utils/version_checker.py b/samcli/lib/utils/version_checker.py index 6c0f64278e..44250446b9 100644 --- a/samcli/lib/utils/version_checker.py +++ b/samcli/lib/utils/version_checker.py @@ -1,6 +1,7 @@ """ Contains information about newer version checker for SAM CLI """ + import logging from datetime import datetime, timedelta from functools import wraps diff --git a/samcli/lib/warnings/sam_cli_warning.py b/samcli/lib/warnings/sam_cli_warning.py index 506529e774..6e5aaf46fa 100644 --- a/samcli/lib/warnings/sam_cli_warning.py +++ b/samcli/lib/warnings/sam_cli_warning.py @@ -1,6 +1,7 @@ """ Provides all Warnings checkers for sam template """ + import logging from typing import Dict diff --git a/samcli/local/apigw/authorizers/authorizer.py b/samcli/local/apigw/authorizers/authorizer.py index 17101b06d2..b25452db0d 100644 --- a/samcli/local/apigw/authorizers/authorizer.py +++ b/samcli/local/apigw/authorizers/authorizer.py @@ -1,6 +1,7 @@ """ Base Authorizer class definition """ + from dataclasses import dataclass diff --git a/samcli/local/apigw/authorizers/lambda_authorizer.py b/samcli/local/apigw/authorizers/lambda_authorizer.py index 8b7b92c6ea..eb4860b975 100644 --- a/samcli/local/apigw/authorizers/lambda_authorizer.py +++ b/samcli/local/apigw/authorizers/lambda_authorizer.py @@ -1,6 +1,7 @@ """ Custom Lambda Authorizer class definition """ + import re from abc import ABC, abstractmethod from dataclasses import dataclass diff --git a/samcli/local/apigw/exceptions.py b/samcli/local/apigw/exceptions.py index 474e51560b..565284186e 100644 --- a/samcli/local/apigw/exceptions.py +++ b/samcli/local/apigw/exceptions.py @@ -1,6 +1,7 @@ """ Exceptions used by API Gateway service """ + from samcli.commands.exceptions import UserException diff --git a/samcli/local/apigw/route.py b/samcli/local/apigw/route.py index 20858265d6..51a64c34f3 100644 --- a/samcli/local/apigw/route.py +++ b/samcli/local/apigw/route.py @@ -1,6 +1,7 @@ """ Route definition for local start-api """ + from typing import List, Optional from samcli.local.apigw.authorizers.authorizer import Authorizer diff --git a/samcli/local/docker/container.py b/samcli/local/docker/container.py index a95d951c1a..508ef5e1ee 100644 --- a/samcli/local/docker/container.py +++ b/samcli/local/docker/container.py @@ -1,6 +1,7 @@ """ Representation of a generic Docker container """ + import io import json import logging diff --git a/samcli/local/docker/container_analyzer.py b/samcli/local/docker/container_analyzer.py index 02916f870a..5e70a4c1fb 100644 --- a/samcli/local/docker/container_analyzer.py +++ b/samcli/local/docker/container_analyzer.py @@ -1,6 +1,7 @@ """ Class for handling the analysis and inspection of Docker containers """ + import logging from dataclasses import dataclass diff --git a/samcli/local/docker/effective_user.py b/samcli/local/docker/effective_user.py index b6ed8ec9b3..0ce23120dc 100644 --- a/samcli/local/docker/effective_user.py +++ b/samcli/local/docker/effective_user.py @@ -1,6 +1,7 @@ """ Representation of an effective user """ + import os from dataclasses import dataclass from typing import Optional diff --git a/samcli/local/docker/exceptions.py b/samcli/local/docker/exceptions.py index 388041e0ff..cc00698083 100644 --- a/samcli/local/docker/exceptions.py +++ b/samcli/local/docker/exceptions.py @@ -1,6 +1,7 @@ """ Docker container related exceptions """ + from samcli.commands.exceptions import UserException diff --git a/samcli/local/docker/lambda_container.py b/samcli/local/docker/lambda_container.py index 0e3a96efad..3eea56c72d 100644 --- a/samcli/local/docker/lambda_container.py +++ b/samcli/local/docker/lambda_container.py @@ -1,6 +1,7 @@ """ Represents Lambda runtime containers. """ + import logging import os from typing import List diff --git a/samcli/local/docker/lambda_image.py b/samcli/local/docker/lambda_image.py index c775a94f4f..b2546de7a3 100644 --- a/samcli/local/docker/lambda_image.py +++ b/samcli/local/docker/lambda_image.py @@ -1,6 +1,7 @@ """ Generates a Docker Image to be used for invoking a function locally """ + import hashlib import logging import os diff --git a/samcli/local/events/api_event.py b/samcli/local/events/api_event.py index f73e554d9a..5a172d6cf8 100644 --- a/samcli/local/events/api_event.py +++ b/samcli/local/events/api_event.py @@ -1,4 +1,5 @@ """Holds Classes for API Gateway to Lambda Events""" + import uuid from datetime import datetime from time import time @@ -242,9 +243,9 @@ def to_dict(self) -> Dict[str, Any]: "resource": self.resource, "requestContext": request_context_dict, "queryStringParameters": dict(self.query_string_params) if self.query_string_params else None, - "multiValueQueryStringParameters": dict(self.multi_value_query_string_params) - if self.multi_value_query_string_params - else None, + "multiValueQueryStringParameters": ( + dict(self.multi_value_query_string_params) if self.multi_value_query_string_params else None + ), "headers": dict(self.headers) if self.headers else None, "multiValueHeaders": dict(self.multi_value_headers) if self.multi_value_headers else None, "pathParameters": dict(self.path_parameters) if self.path_parameters else None, diff --git a/samcli/local/lambdafn/config.py b/samcli/local/lambdafn/config.py index 7a90c3651d..ed9ada46e9 100644 --- a/samcli/local/lambdafn/config.py +++ b/samcli/local/lambdafn/config.py @@ -1,6 +1,7 @@ """ Lambda Function configuration data required by the runtime """ + from samcli.commands.local.cli_common.user_exceptions import InvalidSamTemplateException from .env_vars import EnvironmentVariables diff --git a/samcli/local/lambdafn/runtime.py b/samcli/local/lambdafn/runtime.py index 7e42a53978..5cc276becf 100644 --- a/samcli/local/lambdafn/runtime.py +++ b/samcli/local/lambdafn/runtime.py @@ -1,6 +1,7 @@ """ Classes representing a local Lambda runtime """ + import copy import logging import os diff --git a/samcli/local/services/base_local_service.py b/samcli/local/services/base_local_service.py index 573c24b445..638d55c17b 100644 --- a/samcli/local/services/base_local_service.py +++ b/samcli/local/services/base_local_service.py @@ -1,4 +1,5 @@ """Base class for all Services that interact with Local Lambda""" + import io import json import logging diff --git a/samcli/yamlhelper.py b/samcli/yamlhelper.py index 5dbae210e1..cb7cdbcf6f 100644 --- a/samcli/yamlhelper.py +++ b/samcli/yamlhelper.py @@ -119,9 +119,9 @@ def yaml_parse(yamlstr) -> Dict: # json parser. return cast(Dict, json.loads(yamlstr, object_pairs_hook=OrderedDict)) except ValueError: - yaml.constructor.SafeConstructor.yaml_constructors[ - TIMESTAMP_TAG - ] = yaml.constructor.SafeConstructor.yaml_constructors[TAG_STR] + yaml.constructor.SafeConstructor.yaml_constructors[TIMESTAMP_TAG] = ( + yaml.constructor.SafeConstructor.yaml_constructors[TAG_STR] + ) yaml.SafeLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, _dict_constructor) yaml.SafeLoader.add_multi_constructor("!", intrinsics_multi_constructor) return cast(Dict, yaml.safe_load(yamlstr)) diff --git a/schema/make_schema.py b/schema/make_schema.py index e1d7e889cf..8e1a8e1568 100644 --- a/schema/make_schema.py +++ b/schema/make_schema.py @@ -1,6 +1,5 @@ """Handles JSON schema generation logic""" - import importlib import json from dataclasses import dataclass diff --git a/tests/get_testing_resources.py b/tests/get_testing_resources.py index 2d19a9cd7d..c91a79fd77 100644 --- a/tests/get_testing_resources.py +++ b/tests/get_testing_resources.py @@ -2,6 +2,7 @@ Script for getting test account credentials and managed test account resources. The output will be a json string with creds and resource names. """ + import json import os diff --git a/tests/integration/buildcmd/test_build_cmd.py b/tests/integration/buildcmd/test_build_cmd.py index 4e4f6b3f9d..6edfe8abd6 100644 --- a/tests/integration/buildcmd/test_build_cmd.py +++ b/tests/integration/buildcmd/test_build_cmd.py @@ -1227,9 +1227,11 @@ def test_dotnet_in_process(self, runtime, code_uri, mode, architecture="x86_64") self._verify_built_artifact( self.default_build_dir, self.FUNCTION_LOGICAL_ID, - self.EXPECTED_FILES_PROJECT_MANIFEST - if runtime != "provided.al2" - else self.EXPECTED_FILES_PROJECT_MANIFEST_PROVIDED, + ( + self.EXPECTED_FILES_PROJECT_MANIFEST + if runtime != "provided.al2" + else self.EXPECTED_FILES_PROJECT_MANIFEST_PROVIDED + ), ) self._verify_resource_property( @@ -1298,9 +1300,11 @@ def test_dotnet_in_container_mount_with_write_explicit(self, runtime, code_uri, self._verify_built_artifact( self.default_build_dir, self.FUNCTION_LOGICAL_ID, - self.EXPECTED_FILES_PROJECT_MANIFEST - if runtime != "provided.al2" - else self.EXPECTED_FILES_PROJECT_MANIFEST_PROVIDED, + ( + self.EXPECTED_FILES_PROJECT_MANIFEST + if runtime != "provided.al2" + else self.EXPECTED_FILES_PROJECT_MANIFEST_PROVIDED + ), ) self._verify_resource_property( @@ -1372,9 +1376,11 @@ def test_dotnet_in_container_mount_with_write_interactive( self._verify_built_artifact( self.default_build_dir, self.FUNCTION_LOGICAL_ID, - self.EXPECTED_FILES_PROJECT_MANIFEST - if runtime != "provided.al2" - else self.EXPECTED_FILES_PROJECT_MANIFEST_PROVIDED, + ( + self.EXPECTED_FILES_PROJECT_MANIFEST + if runtime != "provided.al2" + else self.EXPECTED_FILES_PROJECT_MANIFEST_PROVIDED + ), ) self._verify_resource_property( diff --git a/tests/integration/buildcmd/test_build_terraform_applications.py b/tests/integration/buildcmd/test_build_terraform_applications.py index 22fd93c7f0..79131aab76 100644 --- a/tests/integration/buildcmd/test_build_terraform_applications.py +++ b/tests/integration/buildcmd/test_build_terraform_applications.py @@ -80,9 +80,9 @@ def build_with_prepare_hook(self): command_list_parameters["use_container"] = True command_list_parameters["build_image"] = self.docker_tag if self.override: - command_list_parameters[ - "container_env_var" - ] = "TF_VAR_HELLO_FUNCTION_SRC_CODE=./artifacts/HelloWorldFunction2" + command_list_parameters["container_env_var"] = ( + "TF_VAR_HELLO_FUNCTION_SRC_CODE=./artifacts/HelloWorldFunction2" + ) environment_variables = os.environ.copy() if self.override: diff --git a/tests/integration/validate/test_validate_command.py b/tests/integration/validate/test_validate_command.py index 900a3af480..53a36b3472 100644 --- a/tests/integration/validate/test_validate_command.py +++ b/tests/integration/validate/test_validate_command.py @@ -1,6 +1,7 @@ """ Integration tests for sam validate """ + import json import os import re diff --git a/tests/unit/commands/buildcmd/test_utils.py b/tests/unit/commands/buildcmd/test_utils.py index 20a79b3f0f..2784f7c78c 100644 --- a/tests/unit/commands/buildcmd/test_utils.py +++ b/tests/unit/commands/buildcmd/test_utils.py @@ -1,6 +1,7 @@ """ Unit tests for build command utils """ + from unittest import TestCase from unittest.mock import patch diff --git a/tests/unit/commands/deploy/test_deploy_context.py b/tests/unit/commands/deploy/test_deploy_context.py index ad5638ef22..55dff41c94 100644 --- a/tests/unit/commands/deploy/test_deploy_context.py +++ b/tests/unit/commands/deploy/test_deploy_context.py @@ -1,4 +1,5 @@ """Test sam deploy command""" + from unittest import TestCase from unittest.mock import ANY, patch, MagicMock, Mock import tempfile diff --git a/tests/unit/commands/deploy/test_guided_context.py b/tests/unit/commands/deploy/test_guided_context.py index a5137a781b..b52c8fbac5 100644 --- a/tests/unit/commands/deploy/test_guided_context.py +++ b/tests/unit/commands/deploy/test_guided_context.py @@ -35,10 +35,8 @@ def setUp(self): self.companion_stack_manager_mock.return_value.get_unreferenced_repos.return_value = [ self.unreferenced_repo_mock ] - self.companion_stack_manager_mock.return_value.get_repo_uri = ( - lambda repo: "123456789012.dkr.ecr.us-east-1.amazonaws.com/test2" - if repo == self.unreferenced_repo_mock - else None + self.companion_stack_manager_mock.return_value.get_repo_uri = lambda repo: ( + "123456789012.dkr.ecr.us-east-1.amazonaws.com/test2" if repo == self.unreferenced_repo_mock else None ) self.verify_image_patch = patch( diff --git a/tests/unit/commands/local/cli_common/test_invoke_context.py b/tests/unit/commands/local/cli_common/test_invoke_context.py index f30a9574fc..fce1c37f23 100644 --- a/tests/unit/commands/local/cli_common/test_invoke_context.py +++ b/tests/unit/commands/local/cli_common/test_invoke_context.py @@ -1,6 +1,7 @@ """ Tests the InvokeContext class """ + import errno import os diff --git a/tests/unit/commands/local/lib/swagger/test_parser.py b/tests/unit/commands/local/lib/swagger/test_parser.py index 62b3e2c861..7af9041a4e 100644 --- a/tests/unit/commands/local/lib/swagger/test_parser.py +++ b/tests/unit/commands/local/lib/swagger/test_parser.py @@ -1,6 +1,7 @@ """ Test the swagger parser """ + from unittest import TestCase from unittest.mock import ANY, patch, Mock diff --git a/tests/unit/commands/local/lib/test_local_lambda.py b/tests/unit/commands/local/lib/test_local_lambda.py index 1014ea001d..755e6acd0c 100644 --- a/tests/unit/commands/local/lib/test_local_lambda.py +++ b/tests/unit/commands/local/lib/test_local_lambda.py @@ -1,6 +1,7 @@ """ Testing local lambda runner """ + import os import posixpath from unittest import TestCase diff --git a/tests/unit/commands/package/test_package_context.py b/tests/unit/commands/package/test_package_context.py index 682dfba17c..8de0e0fd76 100644 --- a/tests/unit/commands/package/test_package_context.py +++ b/tests/unit/commands/package/test_package_context.py @@ -1,4 +1,5 @@ """Test sam package command""" + from unittest import TestCase from unittest.mock import patch, MagicMock, Mock, call, ANY from parameterized import parameterized diff --git a/tests/unit/commands/publish/test_command.py b/tests/unit/commands/publish/test_command.py index 28bfa716e4..47bb2d53c4 100644 --- a/tests/unit/commands/publish/test_command.py +++ b/tests/unit/commands/publish/test_command.py @@ -1,4 +1,5 @@ """Test sam publish CLI.""" + import json from unittest import TestCase from unittest.mock import patch, call, Mock diff --git a/tests/unit/hook_packages/terraform/hooks/prepare/prepare_base.py b/tests/unit/hook_packages/terraform/hooks/prepare/prepare_base.py index 96193fa757..a65a9c3e61 100644 --- a/tests/unit/hook_packages/terraform/hooks/prepare/prepare_base.py +++ b/tests/unit/hook_packages/terraform/hooks/prepare/prepare_base.py @@ -1,6 +1,7 @@ """ Unit test base class for Terraform prepare hook """ + from unittest import TestCase from samcli.hook_packages.terraform.hooks.prepare.translate import AWS_PROVIDER_NAME, NULL_RESOURCE_PROVIDER_NAME diff --git a/tests/unit/hook_packages/terraform/hooks/prepare/test_enrich.py b/tests/unit/hook_packages/terraform/hooks/prepare/test_enrich.py index 9ae96eb42b..5a21491078 100644 --- a/tests/unit/hook_packages/terraform/hooks/prepare/test_enrich.py +++ b/tests/unit/hook_packages/terraform/hooks/prepare/test_enrich.py @@ -1,4 +1,5 @@ """Test Terraform prepare enrichment""" + from unittest.mock import Mock, call, patch from parameterized import parameterized from subprocess import CalledProcessError diff --git a/tests/unit/hook_packages/terraform/hooks/prepare/test_hook.py b/tests/unit/hook_packages/terraform/hooks/prepare/test_hook.py index a9153c9914..ef56f14df8 100644 --- a/tests/unit/hook_packages/terraform/hooks/prepare/test_hook.py +++ b/tests/unit/hook_packages/terraform/hooks/prepare/test_hook.py @@ -1,4 +1,5 @@ """Test Terraform prepare hook""" + from subprocess import CalledProcessError from unittest.mock import Mock, call, patch, MagicMock, ANY from parameterized import parameterized diff --git a/tests/unit/hook_packages/terraform/hooks/prepare/test_makefile_generator.py b/tests/unit/hook_packages/terraform/hooks/prepare/test_makefile_generator.py index 3aa4a59932..98cab69612 100644 --- a/tests/unit/hook_packages/terraform/hooks/prepare/test_makefile_generator.py +++ b/tests/unit/hook_packages/terraform/hooks/prepare/test_makefile_generator.py @@ -1,4 +1,5 @@ """Test Terraform prepare Makefile""" + from unittest.mock import patch, Mock, call from parameterized import parameterized diff --git a/tests/unit/hook_packages/terraform/hooks/prepare/test_property_builder.py b/tests/unit/hook_packages/terraform/hooks/prepare/test_property_builder.py index 6e8cbfdb4a..3278c0224e 100644 --- a/tests/unit/hook_packages/terraform/hooks/prepare/test_property_builder.py +++ b/tests/unit/hook_packages/terraform/hooks/prepare/test_property_builder.py @@ -1,4 +1,5 @@ """Test Terraform property builder""" + import json from unittest.mock import patch, Mock, call from parameterized import parameterized diff --git a/tests/unit/hook_packages/terraform/hooks/prepare/test_translate.py b/tests/unit/hook_packages/terraform/hooks/prepare/test_translate.py index ea5239f72d..0c664c4697 100644 --- a/tests/unit/hook_packages/terraform/hooks/prepare/test_translate.py +++ b/tests/unit/hook_packages/terraform/hooks/prepare/test_translate.py @@ -1,4 +1,5 @@ """Test Terraform prepare translate""" + import copy from unittest import TestCase from unittest.mock import Mock, call, patch, MagicMock, ANY diff --git a/tests/unit/hook_packages/terraform/hooks/prepare/test_types.py b/tests/unit/hook_packages/terraform/hooks/prepare/test_types.py index 16de4bd21e..1ac534b5ba 100644 --- a/tests/unit/hook_packages/terraform/hooks/prepare/test_types.py +++ b/tests/unit/hook_packages/terraform/hooks/prepare/test_types.py @@ -1,4 +1,5 @@ """Test types""" + from unittest import TestCase from unittest.mock import patch, Mock diff --git a/tests/unit/hook_packages/terraform/lib/test_utils.py b/tests/unit/hook_packages/terraform/lib/test_utils.py index bfda8d97eb..8a7bd9c98d 100644 --- a/tests/unit/hook_packages/terraform/lib/test_utils.py +++ b/tests/unit/hook_packages/terraform/lib/test_utils.py @@ -1,4 +1,5 @@ """Test Terraform utilities""" + from unittest import TestCase from unittest.mock import patch, Mock, call from parameterized import parameterized diff --git a/tests/unit/lib/cli_validation/test_remote_invoke_options_validations.py b/tests/unit/lib/cli_validation/test_remote_invoke_options_validations.py index 32f9f72860..1acba0f7f4 100644 --- a/tests/unit/lib/cli_validation/test_remote_invoke_options_validations.py +++ b/tests/unit/lib/cli_validation/test_remote_invoke_options_validations.py @@ -83,8 +83,8 @@ def test_event_and_remote_event_params(self, patched_click_context): mocked_context = Mock() patched_click_context.return_value = mocked_context - mocked_context.params.get.side_effect = ( - lambda key: "event_content" if key in ("event", "test_event_name") else None + mocked_context.params.get.side_effect = lambda key: ( + "event_content" if key in ("event", "test_event_name") else None ) with self.assertRaises(BadOptionUsage) as ex: @@ -102,8 +102,8 @@ def test_event_file_and_remote_event_params(self, patched_click_context): mocked_context = Mock() patched_click_context.return_value = mocked_context - mocked_context.params.get.side_effect = ( - lambda key: "event_content" if key in ("event_file", "test_event_name") else None + mocked_context.params.get.side_effect = lambda key: ( + "event_content" if key in ("event_file", "test_event_name") else None ) with self.assertRaises(BadOptionUsage) as ex: diff --git a/tests/unit/lib/hook/test_hook_config.py b/tests/unit/lib/hook/test_hook_config.py index ef4a05ebd7..4603b13a03 100644 --- a/tests/unit/lib/hook/test_hook_config.py +++ b/tests/unit/lib/hook/test_hook_config.py @@ -1,4 +1,5 @@ """Test Hook Package Config""" + import json from copy import deepcopy from unittest import TestCase diff --git a/tests/unit/lib/hook/test_hook_wrapper.py b/tests/unit/lib/hook/test_hook_wrapper.py index 370d9f1dbe..9541c031dc 100644 --- a/tests/unit/lib/hook/test_hook_wrapper.py +++ b/tests/unit/lib/hook/test_hook_wrapper.py @@ -1,4 +1,5 @@ """Test Hook Warpper""" + from pathlib import Path from unittest import TestCase from unittest.mock import patch, Mock diff --git a/tests/unit/lib/utils/test_path_utils.py b/tests/unit/lib/utils/test_path_utils.py index e15ec8ea65..c22458269d 100644 --- a/tests/unit/lib/utils/test_path_utils.py +++ b/tests/unit/lib/utils/test_path_utils.py @@ -1,6 +1,7 @@ """ test path_utils module """ + from unittest import TestCase from parameterized import parameterized diff --git a/tests/unit/local/docker/test_container.py b/tests/unit/local/docker/test_container.py index 84003e9e0b..b181ce33fa 100644 --- a/tests/unit/local/docker/test_container.py +++ b/tests/unit/local/docker/test_container.py @@ -1,6 +1,7 @@ """ Unit test for Container class """ + import base64 import json from unittest import TestCase diff --git a/tests/unit/local/docker/test_effective_user.py b/tests/unit/local/docker/test_effective_user.py index cdb255bbb5..126cf41ea2 100644 --- a/tests/unit/local/docker/test_effective_user.py +++ b/tests/unit/local/docker/test_effective_user.py @@ -1,6 +1,7 @@ """ Unit test for EffectiveUser class """ + from unittest import TestCase from unittest.mock import patch diff --git a/tests/unit/local/docker/test_lambda_build_container.py b/tests/unit/local/docker/test_lambda_build_container.py index e260a14704..d62c52e893 100644 --- a/tests/unit/local/docker/test_lambda_build_container.py +++ b/tests/unit/local/docker/test_lambda_build_container.py @@ -1,6 +1,7 @@ """ Unit test for Lambda Build Container management """ + import itertools import json import pathlib diff --git a/tests/unit/local/docker/test_lambda_container.py b/tests/unit/local/docker/test_lambda_container.py index d36aeff841..acce6a5ca7 100644 --- a/tests/unit/local/docker/test_lambda_container.py +++ b/tests/unit/local/docker/test_lambda_container.py @@ -1,6 +1,7 @@ """ Unit test for Lambda container management """ + from unittest import TestCase from unittest.mock import patch, Mock diff --git a/tests/unit/local/docker/test_manager.py b/tests/unit/local/docker/test_manager.py index 87b6af154d..84c6f13a6d 100644 --- a/tests/unit/local/docker/test_manager.py +++ b/tests/unit/local/docker/test_manager.py @@ -1,6 +1,7 @@ """ Tests container manager """ + import importlib from unittest import TestCase from unittest.mock import Mock, patch, MagicMock, ANY, call