Skip to content

Commit

Permalink
feat: mark ServiceFactory.set_kwargs() as deprecated (#660)
Browse files Browse the repository at this point in the history
This moves set_kwargs() from pending deprecation to deprecated. It
doesn't change any behaviour other than the type of warning that it
raises.
  • Loading branch information
lengau authored Feb 24, 2025
1 parent fbbecee commit 52b1768
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions craft_application/services/service_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def set_kwargs(
) -> None:
"""Set up the keyword arguments to pass to a particular service class.
PENDING DEPRECATION: use update_kwargs instead
DEPRECATED: use update_kwargs instead
"""
warnings.warn(
PendingDeprecationWarning(
"ServiceFactory.set_kwargs is pending deprecation. Use update_kwargs instead."
DeprecationWarning(
"ServiceFactory.set_kwargs is deprecated. Use update_kwargs instead."
),
stacklevel=2,
)
Expand Down
8 changes: 8 additions & 0 deletions docs/reference/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Changelog
5.0.0 (2025-Mon-DD)
-------------------

Services
========

- Setting the arguments for a service using the service factory's ``set_kwargs`` is
deprecated. Use ``update_kwargs`` instead or file `an issue
<https://github.com/canonical/craft-application/issues/new?template=bug.yaml>`_
if you still need this method.

Testing
=======

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/services/test_service_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __new__(cls, *args, **kwargs):
app_metadata, project=fake_project, PackageClass=MockPackageService
)

with pytest.warns(PendingDeprecationWarning):
with pytest.warns(DeprecationWarning):
factory.set_kwargs("package", **kwargs)

check.equal(factory.package, MockPackageService.mock_class.return_value)
Expand Down

0 comments on commit 52b1768

Please sign in to comment.