Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ select = [
"F", # Pyflakes
"PL", # pylint
"I", # isort
"TID", # flake8-tidy-imports
]
ignore = ["PLR0913", "PLC0415", "PLW1641"]

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.lint.pylint]
max-branches = 25
max-returns = 8
Expand Down
2 changes: 1 addition & 1 deletion samcli/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import click

from .context import Context
from samcli.cli.context import Context


def debug_option(f):
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/bootstrap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""

# Expose the cli object here
from .command import cli # pragma: no cover
from samcli.commands.bootstrap.command import cli # pragma: no cover
2 changes: 1 addition & 1 deletion samcli/commands/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Expose top level cli command for `init`
"""

from .command import cli
from samcli.commands.init.command import cli
3 changes: 1 addition & 2 deletions samcli/commands/pipeline/bootstrap/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from samcli.cli.main import aws_creds_options, common_options, pass_context, print_cmdline_args
from samcli.commands._utils.click_mutex import ClickMutex
from samcli.commands._utils.command_exception_handler import command_exception_handler
from samcli.commands.pipeline.bootstrap.guided_context import BITBUCKET, GITHUB_ACTIONS, GITLAB, IAM, OPEN_ID_CONNECT
from samcli.commands.pipeline.bootstrap.oidc_config import (
BitbucketOidcConfig,
GitHubOidcConfig,
Expand All @@ -23,8 +24,6 @@
from samcli.lib.telemetry.metric import track_command
from samcli.lib.utils.version_checker import check_newer_version

from .guided_context import BITBUCKET, GITHUB_ACTIONS, GITLAB, IAM, OPEN_ID_CONNECT

SHORT_HELP = "Generates the required AWS resources to connect your CI/CD system."

HELP_TEXT = """
Expand Down
19 changes: 11 additions & 8 deletions samcli/commands/pipeline/init/interactive_init_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
AppPipelineTemplateMetadataException,
PipelineTemplateCloneException,
)
from samcli.commands.pipeline.bootstrap.cli import (
PIPELINE_CONFIG_DIR,
PIPELINE_CONFIG_FILENAME,
_get_bootstrap_command_names,
)
from samcli.commands.pipeline.bootstrap.cli import do_cli as do_bootstrap
from samcli.commands.pipeline.init.pipeline_templates_manifest import (
PipelineTemplateMetadata,
PipelineTemplatesManifest,
Provider,
)
from samcli.lib.config.samconfig import SamConfig
from samcli.lib.cookiecutter.interactive_flow import InteractiveFlow
from samcli.lib.cookiecutter.interactive_flow_creator import InteractiveFlowCreator
Expand All @@ -27,14 +38,6 @@
from samcli.lib.utils.colors import Colored
from samcli.lib.utils.git_repo import CloneRepoException, GitRepo

from ..bootstrap.cli import (
PIPELINE_CONFIG_DIR,
PIPELINE_CONFIG_FILENAME,
_get_bootstrap_command_names,
)
from ..bootstrap.cli import do_cli as do_bootstrap
from .pipeline_templates_manifest import PipelineTemplateMetadata, PipelineTemplatesManifest, Provider

LOG = logging.getLogger(__name__)
shared_path: Path = GlobalConfig().config_dir
APP_PIPELINE_TEMPLATES_REPO_URL = "https://github.com/aws/aws-sam-cli-pipeline-init-templates.git"
Expand Down
2 changes: 1 addition & 1 deletion samcli/hook_packages/terraform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Expose top level prepare hook
"""

from .main import prepare
from samcli.hook_packages.terraform.main import prepare
2 changes: 1 addition & 1 deletion samcli/hook_packages/terraform/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module for Terraform hook entry points
"""

from .hooks.prepare.hook import prepare as prepare_hook
from samcli.hook_packages.terraform.hooks.prepare.hook import prepare as prepare_hook


def prepare(params: dict) -> dict:
Expand Down
4 changes: 2 additions & 2 deletions samcli/lib/cookiecutter/interactive_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import click

from ..utils.colors import Colored
from .question import Question
from samcli.lib.cookiecutter.question import Question
from samcli.lib.utils.colors import Colored


class InteractiveFlow:
Expand Down
5 changes: 2 additions & 3 deletions samcli/lib/cookiecutter/interactive_flow_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
import yaml

from samcli.commands.exceptions import UserException
from samcli.lib.cookiecutter.interactive_flow import InteractiveFlow
from samcli.lib.cookiecutter.question import Question, QuestionFactory
from samcli.yamlhelper import parse_yaml_file

from .interactive_flow import InteractiveFlow
from .question import Question, QuestionFactory


class QuestionsNotFoundException(UserException):
pass
Expand Down
4 changes: 2 additions & 2 deletions samcli/lib/cookiecutter/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from typing import NamedTuple

from .interactive_flow import InteractiveFlow
from .processor import Processor
from samcli.lib.cookiecutter.interactive_flow import InteractiveFlow
from samcli.lib.cookiecutter.processor import Processor


class Plugin(NamedTuple):
Expand Down
14 changes: 9 additions & 5 deletions samcli/lib/cookiecutter/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
from cookiecutter.main import cookiecutter

from samcli.commands.exceptions import UserException
from samcli.lib.cookiecutter.exceptions import (
GenerateProjectFailedError,
InvalidLocationError,
PostprocessingError,
PreprocessingError,
)
from samcli.lib.cookiecutter.interactive_flow import InteractiveFlow
from samcli.lib.cookiecutter.plugin import Plugin
from samcli.lib.cookiecutter.processor import Processor
from samcli.lib.init.arbitrary_project import generate_non_cookiecutter_project

from .exceptions import GenerateProjectFailedError, InvalidLocationError, PostprocessingError, PreprocessingError
from .interactive_flow import InteractiveFlow
from .plugin import Plugin
from .processor import Processor

LOG = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion samcli/lib/hook/hook_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import jsonschema

from .exceptions import InvalidHookPackageConfigException
from samcli.lib.hook.exceptions import InvalidHookPackageConfigException


class HookFunctionality(NamedTuple):
Expand Down
7 changes: 2 additions & 5 deletions samcli/lib/hook/hook_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
from pathlib import Path
from typing import Dict, List, Optional, cast

from .exceptions import (
HookPackageExecuteFunctionalityException,
InvalidHookWrapperException,
)
from .hook_config import HookPackageConfig
from samcli.lib.hook.exceptions import HookPackageExecuteFunctionalityException, InvalidHookWrapperException
from samcli.lib.hook.hook_config import HookPackageConfig

LOG = logging.getLogger(__name__)
INTERNAL_PACKAGES_ROOT = Path(__file__).parent / ".." / ".." / "hook_packages"
Expand Down
5 changes: 2 additions & 3 deletions samcli/lib/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
from cookiecutter.main import cookiecutter

from samcli.lib.config.samconfig import DEFAULT_CONFIG_FILE_EXTENSION, DEFAULT_CONFIG_FILE_NAME
from samcli.lib.init.arbitrary_project import generate_non_cookiecutter_project
from samcli.lib.init.default_samconfig import DefaultSamconfig
from samcli.lib.init.exceptions import GenerateProjectFailedError, InvalidLocationError
from samcli.lib.init.template_modifiers.application_insights_template_modifier import (
ApplicationInsightsTemplateModifier,
)
Expand All @@ -23,9 +25,6 @@
from samcli.lib.utils.packagetype import ZIP
from samcli.local.common.runtime_template import RUNTIME_DEP_TEMPLATE_MAPPING, is_custom_runtime

from .arbitrary_project import generate_non_cookiecutter_project
from .exceptions import GenerateProjectFailedError, InvalidLocationError

LOG = logging.getLogger(__name__)


Expand Down
3 changes: 1 addition & 2 deletions samcli/lib/init/arbitrary_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

from cookiecutter import config, exceptions, repository

from samcli.lib.init.exceptions import ArbitraryProjectDownloadFailed
from samcli.lib.utils import osutils

from .exceptions import ArbitraryProjectDownloadFailed

LOG = logging.getLogger(__name__)


Expand Down
9 changes: 4 additions & 5 deletions samcli/lib/providers/sam_function_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
from samcli.cli.context import Context
from samcli.commands._utils.template import TemplateFailedParsingException
from samcli.commands.local.cli_common.user_exceptions import InvalidLayerVersionArn
from samcli.lib.build.constants import DEPRECATED_RUNTIMES
from samcli.lib.build.exceptions import MissingFunctionHandlerException
from samcli.lib.providers.exceptions import InvalidLayerReference, MissingFunctionNameException
from samcli.lib.providers.provider import Function, LayerVersion, Stack, get_full_path, get_function_build_info
from samcli.lib.providers.sam_base_provider import SamBaseProvider
from samcli.lib.providers.sam_stack_provider import SamLocalStackProvider
from samcli.lib.utils.colors import Colored, Colors
from samcli.lib.utils.file_observer import FileObserver
from samcli.lib.utils.packagetype import IMAGE, ZIP
Expand All @@ -25,11 +29,6 @@
AWS_SERVERLESS_LAYERVERSION,
)

from ..build.constants import DEPRECATED_RUNTIMES
from .provider import Function, LayerVersion, Stack, get_full_path, get_function_build_info
from .sam_base_provider import SamBaseProvider
from .sam_stack_provider import SamLocalStackProvider

LOG = logging.getLogger(__name__)


Expand Down
7 changes: 3 additions & 4 deletions samcli/lib/providers/sam_layer_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import logging
from typing import Dict, List, Optional

from samcli.lib.providers.provider import LayerVersion, Stack
from samcli.lib.providers.sam_base_provider import SamBaseProvider
from samcli.lib.providers.sam_stack_provider import SamLocalStackProvider
from samcli.lib.utils.resources import AWS_LAMBDA_LAYERVERSION, AWS_SERVERLESS_LAYERVERSION

from .provider import LayerVersion, Stack
from .sam_base_provider import SamBaseProvider
from .sam_stack_provider import SamLocalStackProvider

LOG = logging.getLogger(__name__)


Expand Down
3 changes: 1 addition & 2 deletions samcli/lib/samlib/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
from samtranslator.validator.validator import SamTemplateValidator

from samcli.commands.validate.lib.exceptions import InvalidSamDocumentException

from .local_uri_plugin import SupportLocalUriPlugin
from samcli.lib.samlib.local_uri_plugin import SupportLocalUriPlugin


class SamTranslatorWrapper:
Expand Down
5 changes: 2 additions & 3 deletions samcli/local/docker/lambda_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
from typing import List

from samcli.lib.utils.packagetype import IMAGE
from samcli.local.docker.container import DEFAULT_CONTAINER_HOST_INTERFACE, Container
from samcli.local.docker.exceptions import InvalidRuntimeException
from samcli.local.docker.lambda_debug_settings import LambdaDebugSettings

from .container import DEFAULT_CONTAINER_HOST_INTERFACE, Container
from .lambda_image import LambdaImage, Runtime
from samcli.local.docker.lambda_image import LambdaImage, Runtime

LOG = logging.getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions samcli/local/lambda_service/local_lambda_http_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
from samcli.lib.utils.name_utils import InvalidFunctionNameException, normalize_sam_function_identifier
from samcli.lib.utils.stream_writer import StreamWriter
from samcli.local.docker.exceptions import DockerContainerCreationFailedException
from samcli.local.lambda_service.lambda_error_responses import LambdaErrorResponses
from samcli.local.lambdafn.exceptions import DurableExecutionNotFound, FunctionNotFound, UnsupportedInvocationType
from samcli.local.services.base_local_service import BaseLocalService, LambdaOutputParser

from .lambda_error_responses import LambdaErrorResponses

LOG = logging.getLogger(__name__)


Expand Down
3 changes: 1 addition & 2 deletions samcli/local/lambdafn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"""

from samcli.commands.local.cli_common.user_exceptions import InvalidSamTemplateException

from .env_vars import EnvironmentVariables
from samcli.local.lambdafn.env_vars import EnvironmentVariables


class FunctionConfig:
Expand Down
7 changes: 3 additions & 4 deletions samcli/local/lambdafn/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@
import threading
from typing import Dict, Optional, Union

from samcli.lib.providers.provider import LayerVersion
from samcli.lib.telemetry.metric import capture_parameter
from samcli.lib.utils.file_observer import LambdaFunctionObserver
from samcli.lib.utils.invocation_type import EVENT, REQUEST_RESPONSE
from samcli.lib.utils.packagetype import ZIP
from samcli.lib.utils.stream_writer import StreamWriter
from samcli.local.docker.container import Container, ContainerContext
from samcli.local.docker.container_analyzer import ContainerAnalyzer
from samcli.local.docker.durable_functions_emulator_container import DurableFunctionsEmulatorContainer
from samcli.local.docker.durable_lambda_container import DurableLambdaContainer
from samcli.local.docker.exceptions import ContainerFailureError, DockerContainerCreationFailedException
from samcli.local.docker.lambda_container import LambdaContainer
from samcli.local.lambdafn.exceptions import UnsupportedInvocationType

from ...lib.providers.provider import LayerVersion
from ...lib.utils.stream_writer import StreamWriter
from .zip import unzip
from samcli.local.lambdafn.zip import unzip

LOG = logging.getLogger(__name__)

Expand Down
4 changes: 1 addition & 3 deletions samcli/vendor/serverlessrepo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""Common library for AWS Serverless Application Repository."""

from .publish import ( # noqa: F401
publish_application,
)
from samcli.vendor.serverlessrepo.publish import publish_application
2 changes: 1 addition & 1 deletion samcli/vendor/serverlessrepo/application_metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Module containing class to store SAR application metadata."""

from .exceptions import InvalidApplicationMetadataError
from samcli.vendor.serverlessrepo.exceptions import InvalidApplicationMetadataError


class ApplicationMetadata(object):
Expand Down
5 changes: 2 additions & 3 deletions samcli/vendor/serverlessrepo/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

import yaml

from samcli.vendor.serverlessrepo.application_metadata import ApplicationMetadata
from samcli.vendor.serverlessrepo.exceptions import ApplicationMetadataNotFoundError
from samcli.yamlhelper import intrinsics_multi_constructor

from .application_metadata import ApplicationMetadata
from .exceptions import ApplicationMetadataNotFoundError

METADATA = "Metadata"
SERVERLESS_REPO_APPLICATION = "AWS::ServerlessRepo::Application"
APPLICATION_ID_PATTERN = r"arn:[\w\-]+:serverlessrepo:[\w\-]+:[0-9]+:applications\/[\S]+"
Expand Down
14 changes: 9 additions & 5 deletions samcli/vendor/serverlessrepo/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@
import boto3
from botocore.exceptions import ClientError

from samcli.yamlhelper import yaml_dump

from .application_metadata import ApplicationMetadata
from .exceptions import (
from samcli.vendor.serverlessrepo.application_metadata import ApplicationMetadata
from samcli.vendor.serverlessrepo.exceptions import (
DuplicateSemanticVersionError,
InvalidS3UriError,
MissingSemanticVersionError,
S3PermissionsRequired,
ServerlessRepoClientError,
)
from .parser import get_app_metadata, parse_application_id, parse_template, strip_app_metadata
from samcli.vendor.serverlessrepo.parser import (
get_app_metadata,
parse_application_id,
parse_template,
strip_app_metadata,
)
from samcli.yamlhelper import yaml_dump

LOG = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/buildcmd/test_build_cmd_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RUNNING_ON_CI,
CI_OVERRIDE,
)
from .build_integ_base import (
from tests.integration.buildcmd.build_integ_base import (
BuildIntegRustBase,
rust_parameterized_class,
show_container_in_test_name,
Expand Down
Loading
Loading