Skip to content

Commit fdf769d

Browse files
bchampproger-zhanggvicheeyreedham-aws
authored
chore: disallow relative imports (#8403)
* chore: disallow relative imports * fix: fix lint errors after merge conflict resolution --------- Co-authored-by: Roger Zhang <ruojiazh@amazon.com> Co-authored-by: vicheey <181402101+vicheey@users.noreply.github.com> Co-authored-by: Reed Hamilton <reedham@amazon.com>
1 parent 09c3cd5 commit fdf769d

39 files changed

Lines changed: 91 additions & 87 deletions

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,13 @@ select = [
115115
"F", # Pyflakes
116116
"PL", # pylint
117117
"I", # isort
118+
"TID", # flake8-tidy-imports
118119
]
119120
ignore = ["PLR0913", "PLC0415", "PLW1641"]
120121

122+
[tool.ruff.lint.flake8-tidy-imports]
123+
ban-relative-imports = "all"
124+
121125
[tool.ruff.lint.pylint]
122126
max-branches = 25
123127
max-returns = 8

samcli/cli/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import click
77

8-
from .context import Context
8+
from samcli.cli.context import Context
99

1010

1111
def debug_option(f):

samcli/commands/bootstrap/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"""
44

55
# Expose the cli object here
6-
from .command import cli # pragma: no cover
6+
from samcli.commands.bootstrap.command import cli # pragma: no cover

samcli/commands/init/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Expose top level cli command for `init`
33
"""
44

5-
from .command import cli
5+
from samcli.commands.init.command import cli

samcli/commands/pipeline/bootstrap/cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from samcli.commands._utils.click_mutex import ClickMutex
1414
from samcli.commands._utils.command_exception_handler import command_exception_handler
1515
from samcli.commands.pipeline.bootstrap.core.command import PipelineBootstrapCommand
16+
from samcli.commands.pipeline.bootstrap.guided_context import BITBUCKET, GITHUB_ACTIONS, GITLAB, IAM, OPEN_ID_CONNECT
1617
from samcli.commands.pipeline.bootstrap.oidc_config import (
1718
BitbucketOidcConfig,
1819
GitHubOidcConfig,
@@ -24,8 +25,6 @@
2425
from samcli.lib.telemetry.metric import track_command
2526
from samcli.lib.utils.version_checker import check_newer_version
2627

27-
from .guided_context import BITBUCKET, GITHUB_ACTIONS, GITLAB, IAM, OPEN_ID_CONNECT
28-
2928
SHORT_HELP = "Generates the required AWS resources to connect your CI/CD system."
3029

3130
HELP_TEXT = """

samcli/commands/pipeline/init/interactive_init_flow.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818
AppPipelineTemplateMetadataException,
1919
PipelineTemplateCloneException,
2020
)
21+
from samcli.commands.pipeline.bootstrap.cli import (
22+
PIPELINE_CONFIG_DIR,
23+
PIPELINE_CONFIG_FILENAME,
24+
_get_bootstrap_command_names,
25+
)
26+
from samcli.commands.pipeline.bootstrap.cli import do_cli as do_bootstrap
27+
from samcli.commands.pipeline.init.pipeline_templates_manifest import (
28+
PipelineTemplateMetadata,
29+
PipelineTemplatesManifest,
30+
Provider,
31+
)
2132
from samcli.lib.config.samconfig import SamConfig
2233
from samcli.lib.cookiecutter.interactive_flow import InteractiveFlow
2334
from samcli.lib.cookiecutter.interactive_flow_creator import InteractiveFlowCreator
@@ -27,14 +38,6 @@
2738
from samcli.lib.utils.colors import Colored
2839
from samcli.lib.utils.git_repo import CloneRepoException, GitRepo
2940

30-
from ..bootstrap.cli import (
31-
PIPELINE_CONFIG_DIR,
32-
PIPELINE_CONFIG_FILENAME,
33-
_get_bootstrap_command_names,
34-
)
35-
from ..bootstrap.cli import do_cli as do_bootstrap
36-
from .pipeline_templates_manifest import PipelineTemplateMetadata, PipelineTemplatesManifest, Provider
37-
3841
LOG = logging.getLogger(__name__)
3942
shared_path: Path = GlobalConfig().config_dir
4043
APP_PIPELINE_TEMPLATES_REPO_URL = "https://github.com/aws/aws-sam-cli-pipeline-init-templates.git"

samcli/hook_packages/terraform/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Expose top level prepare hook
33
"""
44

5-
from .main import prepare
5+
from samcli.hook_packages.terraform.main import prepare

samcli/hook_packages/terraform/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Module for Terraform hook entry points
33
"""
44

5-
from .hooks.prepare.hook import prepare as prepare_hook
5+
from samcli.hook_packages.terraform.hooks.prepare.hook import prepare as prepare_hook
66

77

88
def prepare(params: dict) -> dict:

samcli/lib/cookiecutter/interactive_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import click
66

7-
from ..utils.colors import Colored
8-
from .question import Question
7+
from samcli.lib.cookiecutter.question import Question
8+
from samcli.lib.utils.colors import Colored
99

1010

1111
class InteractiveFlow:

samcli/lib/cookiecutter/interactive_flow_creator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import yaml
66

77
from samcli.commands.exceptions import UserException
8+
from samcli.lib.cookiecutter.interactive_flow import InteractiveFlow
9+
from samcli.lib.cookiecutter.question import Question, QuestionFactory
810
from samcli.yamlhelper import parse_yaml_file
911

10-
from .interactive_flow import InteractiveFlow
11-
from .question import Question, QuestionFactory
12-
1312

1413
class QuestionsNotFoundException(UserException):
1514
pass

0 commit comments

Comments
 (0)