t-bug-catcher 0.5.4__tar.gz → 0.5.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/PKG-INFO +1 -1
  2. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/setup.cfg +1 -1
  3. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/setup.py +1 -1
  4. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/__init__.py +1 -1
  5. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/bug_catcher.py +0 -7
  6. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/validation.py +33 -33
  7. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/workitems.py +0 -3
  8. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher.egg-info/PKG-INFO +1 -1
  9. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/MANIFEST.in +0 -0
  10. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/README.rst +0 -0
  11. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/pyproject.toml +0 -0
  12. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/requirements.txt +0 -0
  13. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/bug_snag.py +0 -0
  14. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/config.py +0 -0
  15. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/exceptions.py +0 -0
  16. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/jira.py +0 -0
  17. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/resources/whispers_config.yml +0 -0
  18. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/stack_saver.py +0 -0
  19. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/utils/__init__.py +0 -0
  20. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/utils/common.py +0 -0
  21. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher/utils/logger.py +0 -0
  22. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher.egg-info/SOURCES.txt +0 -0
  23. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher.egg-info/dependency_links.txt +0 -0
  24. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher.egg-info/not-zip-safe +0 -0
  25. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher.egg-info/requires.txt +0 -0
  26. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/t_bug_catcher.egg-info/top_level.txt +0 -0
  27. {t_bug_catcher-0.5.4 → t_bug_catcher-0.5.5}/tests/test_t_bug_catcher.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.5.4
3
+ Version: 0.5.5
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.5.4
2
+ current_version = 0.5.5
3
3
  commit = True
4
4
  tag = False
5
5
 
@@ -26,7 +26,7 @@ setup(
26
26
  packages=find_packages(include=["t_bug_catcher", "t_bug_catcher.*"]),
27
27
  test_suite="tests",
28
28
  url="https://www.thoughtful.ai/",
29
- version="0.5.4",
29
+ version="0.5.5",
30
30
  zip_safe=False,
31
31
  install_requires=install_requirements,
32
32
  include_package_data=True,
@@ -3,7 +3,7 @@
3
3
  __author__ = """Thoughtful"""
4
4
  __email__ = "support@thoughtful.ai"
5
5
  # fmt: off
6
- __version__ = '0.5.4'
6
+ __version__ = '0.5.5'
7
7
  # fmt: on
8
8
 
9
9
  from .bug_catcher import (
@@ -12,7 +12,6 @@ from .jira import Jira
12
12
  from .stack_saver import StackSaver
13
13
  from .utils import logger
14
14
  from .utils.common import get_frames
15
- from .validation import PRE_RUN_VALIDATION
16
15
 
17
16
 
18
17
  class Configurator:
@@ -333,9 +332,3 @@ report_error_to_jira = __bug_catcher.report_error_to_jira
333
332
  report_error_to_bugsnag = __bug_catcher.report_error_to_bugsnag
334
333
  install_sys_hook = __bug_catcher.install_sys_hook
335
334
  uninstall_sys_hook = __bug_catcher.uninstall_sys_hook
336
-
337
- if not CONFIG.STAGE:
338
- logger.warning("Implementation Stage is not configured. Please configure it before running.")
339
- else:
340
- if CONFIG.STAGE.lower() == "delivery":
341
- pre_run_validation = PRE_RUN_VALIDATION
@@ -1,6 +1,5 @@
1
1
  import ast
2
2
  import logging
3
- import os
4
3
 
5
4
  from t_bug_catcher.utils.common import strip_path
6
5
 
@@ -13,8 +12,6 @@ console_handler.setLevel(logging.DEBUG)
13
12
  formatter = logging.Formatter("%(levelname)s - %(name)s - %(message)s")
14
13
  validation_logger.addHandler(console_handler)
15
14
 
16
- EXCLUDED_DIRS = [".venv", "venv", "site-packages"]
17
-
18
15
 
19
16
  class IncorrectTryBlockVisitor(ast.NodeVisitor):
20
17
  """A visitor that checks for incorrect try-except blocks."""
@@ -58,11 +55,11 @@ class IncorrectTryBlockVisitor(ast.NodeVisitor):
58
55
  return self.errors
59
56
 
60
57
 
61
- class BroadExceptionWarning:
62
- """A class to represent a broad exception warning."""
58
+ class ValidationWarning:
59
+ """Base class to represent any type of validation warning."""
63
60
 
64
61
  def __init__(self, file_path: str, lineno: int, message: str, source_code: str):
65
- """Initializes the BroadExceptionWarning class."""
62
+ """Initializes the ValidationWarning class."""
66
63
  self.lineno = lineno
67
64
  self.message = message
68
65
  self.__source_code_lines = source_code.split("\n")
@@ -71,29 +68,36 @@ class BroadExceptionWarning:
71
68
  self.file_path = strip_path(file_path)
72
69
 
73
70
 
71
+ class BroadExceptionWarning(ValidationWarning):
72
+ """A class to represent a broad exception warning."""
73
+
74
+ def __init__(self, file_path: str, lineno: int, message: str, source_code: str):
75
+ """Initializes the BroadExceptionWarning class."""
76
+ super().__init__(file_path, lineno, message, source_code)
77
+ self.warning_code = "TBC002"
78
+
79
+
80
+ class ConfigWarning(ValidationWarning):
81
+ """A class to represent a config warning."""
82
+
83
+ def __init__(self, file_path: str, lineno: int, message: str, source_code: str):
84
+ """Initializes the ConfigWarning class."""
85
+ super().__init__(file_path, lineno, message, source_code)
86
+ self.warning_code = "TBC001"
87
+
88
+
74
89
  class PreRunValidation:
75
90
  """A class to perform pre-run validation checks."""
76
91
 
77
92
  def __init__(self):
78
93
  """Initializes the PreRunValidation class."""
79
- self.broad_exception_warnings: list[BroadExceptionWarning] = []
80
- self.analyze_project(os.getcwd())
81
- self.log_warnings()
82
-
83
- def analyze_project(self, project_dir: str):
84
- """Analyzes the project directory for broad exception warnings."""
85
- for root, dirs, files in os.walk(project_dir):
86
- dirs[:] = [d for d in dirs if d not in EXCLUDED_DIRS]
87
- for file in files:
88
- if file.endswith(".py"):
89
- file_path = os.path.join(root, file)
90
-
91
- self.check_broad_exceptions(file_path)
94
+ self.warnings: list[ValidationWarning] = []
92
95
 
93
96
  def check_broad_exceptions(self, filename):
94
97
  """Checks for broad exception warnings in the specified file."""
95
98
  with open(filename, "r", encoding="utf8") as source:
96
99
  source_code = source.read()
100
+
97
101
  try:
98
102
  tree = ast.parse(source_code, filename=filename)
99
103
  except SyntaxError:
@@ -102,22 +106,18 @@ class PreRunValidation:
102
106
  validation_logger.error(f"Unable to validate: {filename} - {ex}")
103
107
  return
104
108
 
105
- visitor = IncorrectTryBlockVisitor()
106
- visitor.visit(tree)
109
+ visitor = IncorrectTryBlockVisitor()
110
+ visitor.visit(tree)
107
111
 
108
112
  for line, message in visitor.get_errors().items():
109
113
  be_warn = BroadExceptionWarning(filename, line, message, source_code=source_code)
110
- self.broad_exception_warnings.append(be_warn)
111
-
112
- def log_warnings(self):
113
- """Logs the broad exception warnings."""
114
- for be_warn in self.broad_exception_warnings:
115
- validation_logger.warning(f"{be_warn.file_path}:{be_warn.lineno}: {be_warn.message}")
116
-
117
- @property
118
- def errors_count(self):
119
- """Property to define the number of errors. Used for pre-commit hook."""
120
- return len(self.broad_exception_warnings)
114
+ self.warnings.append(be_warn)
121
115
 
116
+ def check_configuration_exceptions(self, filename):
117
+ """Checks for configurations warnings in the specified file."""
118
+ pass
122
119
 
123
- PRE_RUN_VALIDATION = PreRunValidation()
120
+ def validate_file(self, filename):
121
+ """Checks for warnings in the specified file."""
122
+ self.check_broad_exceptions(filename)
123
+ self.check_configuration_exceptions(filename)
@@ -1,5 +1,3 @@
1
- from .utils import logger
2
-
3
1
  try:
4
2
  from RPA.Robocorp.WorkItems import WorkItems
5
3
 
@@ -9,6 +7,5 @@ try:
9
7
  variables = work_item.get("variables", dict())
10
8
  metadata = work_item.get("metadata", dict())
11
9
  except (ImportError, KeyError):
12
- logger.warning("Workitems unavailable. Variables will be empty.")
13
10
  variables = {}
14
11
  metadata = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.5.4
3
+ Version: 0.5.5
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
File without changes
File without changes