Skip to content

Commit

Permalink
Move WarningsConfigError to new file exceptions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperCraeghs committed Jan 25, 2024
1 parent db59768 commit 427f647
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/mlx/warnings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
'XMLRunnerChecker',
'__version__',
'warnings_wrapper',
'WarningsConfigError',
]


from .__version__ import __version__
from .exceptions import WarningsConfigError
from .junit_checker import JUnitChecker
from .regex_checker import CoverityChecker, DoxyChecker, SphinxChecker, XMLRunnerChecker
from .robot_checker import RobotChecker, RobotSuiteChecker
Expand Down
2 changes: 2 additions & 0 deletions src/mlx/warnings/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class WarningsConfigError(Exception):
pass
3 changes: 0 additions & 3 deletions src/mlx/warnings/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
__version__ = distribution('mlx.warnings').version


class WarningsConfigError(Exception):
pass


def substitute_envvar(checker_config, keys):
"""Modifies configuration for checker in-place, resolving any environment variables for ``keys``
Expand Down
6 changes: 4 additions & 2 deletions src/mlx/warnings/warnings_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import re
from string import Template

from .exceptions import WarningsConfigError


class WarningsChecker:
name = 'checker'
Expand Down Expand Up @@ -41,8 +43,8 @@ def cq_description_template(self, template_obj):
try:
template_obj.template = template_obj.substitute(os.environ, description='$description')
except KeyError as err:
raise ValueError(f"Failed to find environment variable from configuration value "
f"'cq_description_template': {err}") from err
raise WarningsConfigError(f"Failed to find environment variable from configuration value "
f"'cq_description_template': {err}") from err
self._cq_description_template = template_obj

@abc.abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from unittest.mock import patch

from mlx.warnings import warnings_wrapper
from mlx.warnings import warnings_wrapper, WarningsConfigError

TEST_IN_DIR = Path(__file__).parent / 'test_in'
TEST_OUT_DIR = Path(__file__).parent / 'test_out'
Expand Down Expand Up @@ -334,7 +334,7 @@ def test_cq_description_format_missing_envvar(self):
os.environ['FIRST_ENVVAR'] = 'envvar_value'
filename = 'code_quality_format.json'
out_file = str(TEST_OUT_DIR / filename)
with self.assertRaises(ValueError) as c_m:
with self.assertRaises(WarningsConfigError) as c_m:
warnings_wrapper([
'--code-quality', out_file,
'--config', 'tests/test_in/config_cq_description_format.json',
Expand Down

0 comments on commit 427f647

Please sign in to comment.