Skip to content

Commit

Permalink
style: make linting happy
Browse files Browse the repository at this point in the history
  • Loading branch information
james-garner-canonical committed Dec 4, 2024
1 parent 08aa90d commit 8008a97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/charms/operator_libs_linux/v0/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,9 +927,8 @@ class InvalidSourceError(Error):

class MissingRequiredKeyError(InvalidSourceError):
"""Missing a required value in a source file."""
def __init__(
self, message: str = "", *, file: str, line: Optional[int], key: str
) -> None:

def __init__(self, message: str = "", *, file: str, line: Optional[int], key: str) -> None:
super().__init__(message, file, line, key)
self.file = file
self.line = line
Expand All @@ -938,6 +937,7 @@ def __init__(

class BadValueError(InvalidSourceError):
"""Bad value for an entry in a source file."""

def __init__(
self,
message: str = "",
Expand Down
12 changes: 4 additions & 8 deletions tests/unit/test_deb822.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ def test_load_deb822_components_with_exact_path(repo_mapping: apt.RepositoryMapp

def test_load_deb822_bad_enabled_value(repo_mapping: apt.RepositoryMapping):
with pytest.raises(apt.InvalidSourceError):
repo_mapping.load_deb822(
str(SOURCES_DIR / "bad-stanza-enabled-bad.sources")
)
repo_mapping.load_deb822(str(SOURCES_DIR / "bad-stanza-enabled-bad.sources"))
assert len(repo_mapping._last_errors) == 1
[error] = repo_mapping._last_errors
assert isinstance(error, apt.BadValueError)
Expand All @@ -170,9 +168,7 @@ def test_load_deb822_bad_enabled_value(repo_mapping: apt.RepositoryMapping):

def test_load_deb822_missing_required_keys(repo_mapping: apt.RepositoryMapping):
with pytest.raises(apt.InvalidSourceError):
repo_mapping.load_deb822(
str(SOURCES_DIR / "bad-stanza-missing-required-keys.sources")
)
repo_mapping.load_deb822(str(SOURCES_DIR / "bad-stanza-missing-required-keys.sources"))
assert len(repo_mapping._last_errors) == 1
[error] = repo_mapping._last_errors
assert isinstance(error, apt.MissingRequiredKeyError)
Expand Down Expand Up @@ -358,8 +354,8 @@ def test_add_with_deb822(repo_mapping: apt.RepositoryMapping):
capture_output=True,
)
# we re-raise CalledProcessError after logging
error = apt.CalledProcessError(1, 'cmd')
error.stdout = error.stderr = b''
error = apt.CalledProcessError(1, "cmd")
error.stdout = error.stderr = b""
with patch.object(apt.logger, "error") as mock_logging_error:
with patch.object(apt.subprocess, "run", side_effect=error):
with pytest.raises(apt.CalledProcessError):
Expand Down

0 comments on commit 8008a97

Please sign in to comment.