diff --git a/snap/CHANGELOG.md b/snap/CHANGELOG.md index 6678aac35..50e407b73 100644 --- a/snap/CHANGELOG.md +++ b/snap/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.0.1 - 4 November 2025 + +Update the type annotation of `log`'s `num_lines` parameter to indicate that `'all'` is accepted. + # 1.0.0.post0 - 14 October 2025 Update project URLs. diff --git a/snap/src/charmlibs/snap/_snap.py b/snap/src/charmlibs/snap/_snap.py index ca9eaff46..42ee18624 100644 --- a/snap/src/charmlibs/snap/_snap.py +++ b/snap/src/charmlibs/snap/_snap.py @@ -424,13 +424,12 @@ def stop(self, services: list[str] | None = None, disable: bool = False) -> None args = ['stop', '--disable'] if disable else ['stop'] self._snap_daemons(args, services) - def logs(self, services: list[str] | None = None, num_lines: int = 10) -> str: + def logs(self, services: list[str] | None = None, num_lines: int | Literal['all'] = 10) -> str: """Fetch a snap services' logs. Args: - services (list): (optional) list of individual snap services to show logs from - (otherwise all) - num_lines (int): (optional) integer number of log lines to return. Default `10` + services: individual snap services to show logs from. Includes all by default. + num_lines: number of log lines to return, or 'all'. Returns 10 by default. """ args = ['logs', f'-n={num_lines}'] if num_lines else ['logs'] return self._snap_daemons(args, services).stdout diff --git a/snap/src/charmlibs/snap/_version.py b/snap/src/charmlibs/snap/_version.py index fb0199b45..fba7cb9a9 100644 --- a/snap/src/charmlibs/snap/_version.py +++ b/snap/src/charmlibs/snap/_version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = '1.0.0.post0' +__version__ = '1.0.1' diff --git a/snap/tests/unit/test_snap.py b/snap/tests/unit/test_snap.py index 424bc0188..02e4caaf4 100644 --- a/snap/tests/unit/test_snap.py +++ b/snap/tests/unit/test_snap.py @@ -345,6 +345,14 @@ def test_can_run_snap_daemon_commands(self, mock_subprocess: MagicMock): capture_output=True, ) + foo.logs(num_lines='all') + mock_subprocess.assert_called_with( + ['snap', 'logs', '-n=all', 'foo'], + text=True, + check=True, + capture_output=True, + ) + foo.logs(services=['bar', 'baz'], num_lines=0) # falsey num_lines is ignored mock_subprocess.assert_called_with( ['snap', 'logs', 'foo.bar', 'foo.baz'],