From 4ea86413438d9b5a9426ec3d7d6bdd08facfab73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Job?= Date: Thu, 7 Sep 2023 13:50:47 +0200 Subject: [PATCH] Create new subpackage for app's internal modules (#362) --- .pre-commit-config.yaml | 2 +- pyproject.toml | 2 +- snowcli.spec | 2 +- src/snowcli/{ => app}/__init__.py | 0 src/snowcli/{ => app}/__main__.py | 2 +- src/snowcli/{cli/app.py => app/cli_app.py} | 8 +++++--- src/snowcli/{cli/main => app/dev}/__init__.py | 0 src/snowcli/{ => app/dev}/docs/__init__.py | 0 src/snowcli/{ => app/dev}/docs/generator.py | 0 .../{ => app/dev}/docs/templates/overview.rst.jinja2 | 0 src/snowcli/{ => app/dev}/docs/templates/usage.rst.jinja2 | 0 src/snowcli/{ => app/dev}/pycharm_remote_debug.py | 0 .../main/snow_cli_main_typer.py => app/main_typer.py} | 0 tests/test_main.py | 2 +- tests/testing_utils/fixtures.py | 2 +- tests_integration/conftest.py | 2 +- 16 files changed, 12 insertions(+), 10 deletions(-) rename src/snowcli/{ => app}/__init__.py (100%) rename src/snowcli/{ => app}/__main__.py (83%) rename src/snowcli/{cli/app.py => app/cli_app.py} (93%) rename src/snowcli/{cli/main => app/dev}/__init__.py (100%) rename src/snowcli/{ => app/dev}/docs/__init__.py (100%) rename src/snowcli/{ => app/dev}/docs/generator.py (100%) rename src/snowcli/{ => app/dev}/docs/templates/overview.rst.jinja2 (100%) rename src/snowcli/{ => app/dev}/docs/templates/usage.rst.jinja2 (100%) rename src/snowcli/{ => app/dev}/pycharm_remote_debug.py (100%) rename src/snowcli/{cli/main/snow_cli_main_typer.py => app/main_typer.py} (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6df6f785c..63a6a945a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: - id: check-yaml exclude: .github/repo_meta.yaml - id: debug-statements - exclude: src/snowcli/pycharm_remote_debug.py + exclude: src/snowcli/app/dev/pycharm_remote_debug.py - id: check-ast - repo: https://github.com/charliermarsh/ruff-pre-commit rev: "v0.0.217" diff --git a/pyproject.toml b/pyproject.toml index cf6ca2927..8374bbe73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ dev = [ "Bug Tracker" = "https://github.com/Snowflake-Labs/snowcli/issues" [project.scripts] -snow = "snowcli.__main__:main" +snow = "snowcli.app.__main__:main" [tool.hatch.version] path = "src/snowcli/__about__.py" diff --git a/snowcli.spec b/snowcli.spec index 7d00b3df1..56a023df9 100644 --- a/snowcli.spec +++ b/snowcli.spec @@ -5,7 +5,7 @@ block_cipher = None a = Analysis( - ['src/snowcli/cli/__init__.py'], + ['src/snowcli/app/__main__.py'], pathex=[], binaries=[], datas=[('src/templates', 'templates'), ('src/snowcli', 'snowcli')], diff --git a/src/snowcli/__init__.py b/src/snowcli/app/__init__.py similarity index 100% rename from src/snowcli/__init__.py rename to src/snowcli/app/__init__.py diff --git a/src/snowcli/__main__.py b/src/snowcli/app/__main__.py similarity index 83% rename from src/snowcli/__main__.py rename to src/snowcli/app/__main__.py index 46076a126..199a0d3c9 100644 --- a/src/snowcli/__main__.py +++ b/src/snowcli/app/__main__.py @@ -2,7 +2,7 @@ import sys -from snowcli.cli.app import app +from snowcli.app.cli_app import app def main(*args): diff --git a/src/snowcli/cli/app.py b/src/snowcli/app/cli_app.py similarity index 93% rename from src/snowcli/cli/app.py rename to src/snowcli/app/cli_app.py index 29f3f87a4..f099eb0a4 100644 --- a/src/snowcli/cli/app.py +++ b/src/snowcli/app/cli_app.py @@ -8,12 +8,14 @@ import click from snowcli import __about__ -from snowcli.cli.main.snow_cli_main_typer import SnowCliMainTyper +from snowcli.app.main_typer import SnowCliMainTyper from snowcli.config import config_init, cli_config -from snowcli.docs.generator import generate_docs +from snowcli.app.dev.docs.generator import generate_docs from snowcli.output.formats import OutputFormat from snowcli.output.printing import OutputData -from snowcli.pycharm_remote_debug import setup_pycharm_remote_debugger_if_provided +from snowcli.app.dev.pycharm_remote_debug import ( + setup_pycharm_remote_debugger_if_provided, +) app: SnowCliMainTyper = SnowCliMainTyper() log = logging.getLogger(__name__) diff --git a/src/snowcli/cli/main/__init__.py b/src/snowcli/app/dev/__init__.py similarity index 100% rename from src/snowcli/cli/main/__init__.py rename to src/snowcli/app/dev/__init__.py diff --git a/src/snowcli/docs/__init__.py b/src/snowcli/app/dev/docs/__init__.py similarity index 100% rename from src/snowcli/docs/__init__.py rename to src/snowcli/app/dev/docs/__init__.py diff --git a/src/snowcli/docs/generator.py b/src/snowcli/app/dev/docs/generator.py similarity index 100% rename from src/snowcli/docs/generator.py rename to src/snowcli/app/dev/docs/generator.py diff --git a/src/snowcli/docs/templates/overview.rst.jinja2 b/src/snowcli/app/dev/docs/templates/overview.rst.jinja2 similarity index 100% rename from src/snowcli/docs/templates/overview.rst.jinja2 rename to src/snowcli/app/dev/docs/templates/overview.rst.jinja2 diff --git a/src/snowcli/docs/templates/usage.rst.jinja2 b/src/snowcli/app/dev/docs/templates/usage.rst.jinja2 similarity index 100% rename from src/snowcli/docs/templates/usage.rst.jinja2 rename to src/snowcli/app/dev/docs/templates/usage.rst.jinja2 diff --git a/src/snowcli/pycharm_remote_debug.py b/src/snowcli/app/dev/pycharm_remote_debug.py similarity index 100% rename from src/snowcli/pycharm_remote_debug.py rename to src/snowcli/app/dev/pycharm_remote_debug.py diff --git a/src/snowcli/cli/main/snow_cli_main_typer.py b/src/snowcli/app/main_typer.py similarity index 100% rename from src/snowcli/cli/main/snow_cli_main_typer.py rename to src/snowcli/app/main_typer.py diff --git a/tests/test_main.py b/tests/test_main.py index 1af3105b0..8ee9fe493 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -62,7 +62,7 @@ def test_info_callback(runner): def test_all_commands_has_proper_documentation(): - from snowcli.cli.app import app + from snowcli.app.cli_app import app ctx = click.Context(get_command(app)) errors = [] diff --git a/tests/testing_utils/fixtures.py b/tests/testing_utils/fixtures.py index 832f5ca2a..dd3adef9c 100644 --- a/tests/testing_utils/fixtures.py +++ b/tests/testing_utils/fixtures.py @@ -150,7 +150,7 @@ def package_file(): @pytest.fixture(scope="function") def runner(test_snowcli_config): - from snowcli.cli.app import app + from snowcli.app.cli_app import app return SnowCLIRunner(app, test_snowcli_config) diff --git a/tests_integration/conftest.py b/tests_integration/conftest.py index 4844d42a7..dd62236d4 100644 --- a/tests_integration/conftest.py +++ b/tests_integration/conftest.py @@ -5,7 +5,7 @@ import pytest from dataclasses import dataclass from pathlib import Path -from snowcli.cli.app import app +from snowcli.app.cli_app import app from tempfile import NamedTemporaryFile from typer import Typer from typer.testing import CliRunner