From 245be31bb6b4eb134324d6adaff2972a02c25677 Mon Sep 17 00:00:00 2001 From: Ritika Date: Sat, 3 Aug 2024 18:56:33 +0530 Subject: [PATCH 1/2] Add pydocstyle workflow and docstring Related to https://github.com/StackGuardian/tirith/issues/90 --- .github/workflows/pydosctyle.yml | 25 +++++++++++++++++++++++++ .pydocstyle | 2 ++ src/tirith/logging.py | 11 +++++++++++ 3 files changed, 38 insertions(+) create mode 100644 .github/workflows/pydosctyle.yml create mode 100644 .pydocstyle diff --git a/.github/workflows/pydosctyle.yml b/.github/workflows/pydosctyle.yml new file mode 100644 index 00000000..2e52c31c --- /dev/null +++ b/.github/workflows/pydosctyle.yml @@ -0,0 +1,25 @@ +name: Lint and Test + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pydocstyle + + - name: Run pydocstyle + run: | + pydocstyle diff --git a/.pydocstyle b/.pydocstyle new file mode 100644 index 00000000..f5ddec23 --- /dev/null +++ b/.pydocstyle @@ -0,0 +1,2 @@ +[pydocstyle] +ignore = D203,D213,D406,D407,D415,D100,D101,D102,D103,D104,D107,D200,D205,D212,D400,D401,D402,D404 diff --git a/src/tirith/logging.py b/src/tirith/logging.py index 121b4ebe..5d055022 100644 --- a/src/tirith/logging.py +++ b/src/tirith/logging.py @@ -1,3 +1,7 @@ +""" +Sets up logging configuration for the application. +""" + import logging import logging.config import sys @@ -38,6 +42,13 @@ def setup_logging(verbose: bool = False): + """ + Set up logging configuration. + + :param verbose: If set to `True` will log all messages higher than DEBUG + level, otherwise it will log the messages that are higher + than INFO level ('INFO', 'WARNING', 'CRITICAL') + """ if verbose: DEFAULT_LOGGING_CONFIG["root"]["handlers"] = ["console_stderr_verbose"] logging.config.dictConfig(DEFAULT_LOGGING_CONFIG) From 5eef345e2d908c546313bceaa7ce25e800ffa219 Mon Sep 17 00:00:00 2001 From: Denish Tomar <152975472+Denish3436@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:10:58 +0530 Subject: [PATCH 2/2] Fixed error messages in handler.py (#197) --- src/tirith/providers/terraform_plan/handler.py | 8 ++++---- tests/providers/terraform_plan/test_direct_references.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tirith/providers/terraform_plan/handler.py b/src/tirith/providers/terraform_plan/handler.py index 3b7a3166..4bedafb2 100644 --- a/src/tirith/providers/terraform_plan/handler.py +++ b/src/tirith/providers/terraform_plan/handler.py @@ -204,7 +204,7 @@ def provider_config_operator(input_data: dict, provider_inputs: dict, outputs: l outputs.append( { "value": ProviderError(severity_value=99), - "err": "`terraform_provider_full_name` must be provided in the provider input (severity_value: 99))", + "err": "`terraform_provider_full_name` must be provided in the provider input (severity_value: 99)", } ) return @@ -274,7 +274,7 @@ def direct_dependencies_operator(input_data: dict, provider_inputs: dict, output outputs.append( { "value": ProviderError(severity_value=99), - "err": "`terraform_resource_type` must be provided in the provider input (severity_value: 99))", + "err": "`terraform_resource_type` must be provided in the provider input (severity_value: 99)", } ) return @@ -453,7 +453,7 @@ def direct_references_operator(input_data: dict, provider_inputs: dict, outputs: outputs.append( { "value": ProviderError(severity_value=99), - "err": "Only one of `referenced_by` or `references_to` must be provided in the provider input (severity_value: 99))", + "err": "Only one of `referenced_by` or `references_to` must be provided in the provider input (severity_value: 99)", } ) return @@ -471,7 +471,7 @@ def direct_references_operator(input_data: dict, provider_inputs: dict, outputs: outputs.append( { "value": ProviderError(severity_value=99), - "err": "`terraform_resource_type` must be provided in the provider input (severity_value: 99))", + "err": "`terraform_resource_type` must be provided in the provider input (severity_value: 99)", } ) return diff --git a/tests/providers/terraform_plan/test_direct_references.py b/tests/providers/terraform_plan/test_direct_references.py index 293d63a6..81a1c3c0 100644 --- a/tests/providers/terraform_plan/test_direct_references.py +++ b/tests/providers/terraform_plan/test_direct_references.py @@ -79,7 +79,7 @@ def test_direct_references_to_and_by_should_raise_error(): "Only one of `referenced_by` or " "`references_to` must be provided in " "the provider input (severity_value: " - "99))" + "99)" )