Skip to content

Commit

Permalink
fixing some small ruff errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dbatten5 committed Oct 18, 2023
1 parent c7e1e79 commit ddc00c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
6 changes: 2 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def _create_toml(
) -> Path:
content = content or {}
config_toml = toml.dumps(content)
toml_path = create_tmp_file(content=config_toml, filename=filename)
return toml_path
return create_tmp_file(content=config_toml, filename=filename)

return _create_toml

Expand All @@ -48,7 +47,6 @@ def _create_pyproject_toml(
) -> Path:
content = content or {"bar": "baz"}
config_dict = {"tool": {section_name: content}}
pyproject_path = create_toml(filename=filename, content=config_dict)
return pyproject_path
return create_toml(filename=filename, content=config_dict)

return _create_pyproject_toml
4 changes: 2 additions & 2 deletions tests/unit/config_sources/test_toml_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from textwrap import dedent
from typing import Callable

from pytest import raises
import pytest

from maison.config_sources.toml_source import TomlSource
from maison.errors import BadTomlError
Expand Down Expand Up @@ -44,5 +44,5 @@ def test_toml_decode_error(self, create_toml: Callable[..., Path]) -> None:
toml_source = TomlSource(filepath=toml_path, project_name="acme")

error_regex = re.escape(f"Error trying to load toml file '{str(toml_path)}'")
with raises(BadTomlError, match=error_regex):
with pytest.raises(BadTomlError, match=error_regex):
toml_source.to_dict()
14 changes: 6 additions & 8 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from unittest.mock import MagicMock
from unittest.mock import patch

from pytest import mark
from pytest import param
from pytest import raises
import pytest

from maison.utils import deep_merge
from maison.utils import get_file_path
Expand Down Expand Up @@ -125,16 +123,16 @@ def test_absolute_path_not_exist(self) -> None:
class TestDeepMerge:
"""Tests for the `deep_merge` function."""

@mark.parametrize(
"a,b,expected",
@pytest.mark.parametrize(
("a", "b", "expected"),
[
param(
pytest.param(
{1: 2, 3: 4},
{3: 5, 6: 7},
{1: 2, 3: 5, 6: 7},
id="simple",
),
param(
pytest.param(
{1: 2, 3: {4: 5, 6: 7}},
{3: {6: 8, 9: 10}, 11: 12},
{1: 2, 3: {4: 5, 6: 8, 9: 10}, 11: 12},
Expand Down Expand Up @@ -165,5 +163,5 @@ def test_incompatible_dicts(self) -> None:
dict_a = {1: 2, 2: 5}
dict_b = {1: {3: 4}}

with raises(RuntimeError):
with pytest.raises(RuntimeError):
deep_merge(dict_a, dict_b)

0 comments on commit ddc00c9

Please sign in to comment.