Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some ruff linting issues. #31

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/py_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ jobs:
if: ${{ always() }}

- name: Linting with Ruff
run: ruff --output-format=github .
run: ruff check --ignore=E721,E722,E401 --output-format=github .
# continue-on-error: true # need to remove this later on to catch the errors anf fail the workflow on linting errors

3 changes: 2 additions & 1 deletion src/app_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ def _perform_checks(self, check_type="APP_INSPECT"):
try:
response = requests.request("GET", "{}/{}".format(
self.STATUS_CHECK_URL, request_id), headers=self.headers, data={}, timeout=TIMEOUT_MAX)
except:
except Exception as e:
# continue if there is any error (specifically 10 times for timeout error)
utils.debug(f"No action needed. {e}")
continue

utils.info("App package status check (check_type={}) response: status_code={}, text={}".format(
Expand Down
1 change: 0 additions & 1 deletion src/helpers/splunk_app_details.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import json
import helpers.github_action_utils as utils
from helpers.splunk_config_parser import SplunkConfigParser
Expand Down
1 change: 0 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import shutil
import sys
import re
import traceback

sys.path.append(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion src/ucc_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def build():
utils.info("Running ucc-gen command.")

# copy folder to generate build, rather than affecting the original repo checkout
utils.execute_system_command(f"rm -rf ucc_build_dir")
utils.execute_system_command("rm -rf ucc_build_dir")
shutil.copytree(GlobalVariables.ORIGINAL_REPO_DIR_NAME, "ucc_build_dir")

org_ta_dir = os.path.join(GlobalVariables.ORIGINAL_REPO_DIR_NAME, GlobalVariables.APP_DIR_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ def modify_original_input_py_file(addon_name, input_name):
# print(f"file_content2 = {file_content}")

# Update validate_input method
pattern_validate_input_fun = rf"def validate_input[\w\W]*return\n"
pattern_validate_input_fun = r"def validate_input[\w\W]*return\n"
replacement_content_validate_input_fun = f"def validate_input(self, definition: smi.ValidationDefinition):\n {input_name}_handler.validate_input(self, definition)\n\n"

file_content = re.sub(pattern_validate_input_fun, replacement_content_validate_input_fun, file_content)

# print(f"file_content3 = {file_content}")

# Update stream_events method
pattern_stream_events_fun = rf"def stream_events[\w\W]*(?:\n\n)"
pattern_stream_events_fun = r"def stream_events[\w\W]*(?:\n\n)"
replacement_content_stream_events_fun = f"def stream_events(self, inputs: smi.InputDefinition, event_writer: smi.EventWriter):\n {input_name}_handler.stream_events(self, inputs, event_writer)\n\n\n"

file_content = re.sub(pattern_stream_events_fun, replacement_content_stream_events_fun, file_content)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_splunk_app_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_fetch_app_package_id_from_app_conf_valid():
[package]
id = my_app
''') as file_path:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception):
app_package_id = fetch_app_package_id_from_app_conf(file_path)
assert app_package_id == "my_app"

Expand Down
6 changes: 3 additions & 3 deletions tests/test_splunk_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def _util_conf_path(self, file_name):

def test_file_not_found(self):
with self.assertRaises(Exception):
conf = SplunkConfigParser(self._util_conf_path('no_file.conf'))
SplunkConfigParser(self._util_conf_path('no_file.conf'))

def test_read_config_file(self):
conf = SplunkConfigParser(self._util_conf_path('read_config_file.conf'))
assert conf != None
assert conf is not None

def test_get_config_sections(self):
conf = SplunkConfigParser(self._util_conf_path('read_config_file.conf'))
Expand Down Expand Up @@ -55,7 +55,7 @@ def test_parse_2_multiline_value(self):

def test_invalid_config(self):
with self.assertRaisesRegex(Exception, "SplunkConfigParser: Unable to parse the Splunk config file properly."):
conf = SplunkConfigParser(self._util_conf_path('invalid_config.conf'))
SplunkConfigParser(self._util_conf_path('invalid_config.conf'))

def test_empty_config(self):
conf = SplunkConfigParser(self._util_conf_path('empty_config.conf'))
Expand Down
Loading