Skip to content

Commit da61683

Browse files
committed
chore: disallow relative imports
1 parent 9c923df commit da61683

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
@@ -10,9 +10,13 @@ select = [
1010
"F", # Pyflakes
1111
"PL", # pylint
1212
"I", # isort
13+
"TID", # flake8-tidy-imports
1314
]
1415
ignore = ["PLR0913", "PLC0415", "PLW1641"]
1516

17+
[tool.ruff.lint.flake8-tidy-imports]
18+
ban-relative-imports = "all"
19+
1620
[tool.ruff.lint.pylint]
1721
max-branches = 25
1822
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
@@ -12,6 +12,7 @@
1212
from samcli.cli.main import aws_creds_options, common_options, pass_context, print_cmdline_args
1313
from samcli.commands._utils.click_mutex import ClickMutex
1414
from samcli.commands._utils.command_exception_handler import command_exception_handler
15+
from samcli.commands.pipeline.bootstrap.guided_context import BITBUCKET, GITHUB_ACTIONS, GITLAB, IAM, OPEN_ID_CONNECT
1516
from samcli.commands.pipeline.bootstrap.oidc_config import (
1617
BitbucketOidcConfig,
1718
GitHubOidcConfig,
@@ -23,8 +24,6 @@
2324
from samcli.lib.telemetry.metric import track_command
2425
from samcli.lib.utils.version_checker import check_newer_version
2526

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

3029
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)