diff --git a/ops/_private/yaml.py b/ops/_private/yaml.py index 97d7ae694..8729d5ce4 100644 --- a/ops/_private/yaml.py +++ b/ops/_private/yaml.py @@ -32,6 +32,8 @@ def safe_load(stream: Union[str, TextIO]): def safe_dump(data: Any, *args: Any, encoding: None = None, **kwargs: Any) -> str: ... # noqa @overload def safe_dump(data: Any, *args: Any, encoding: str = "", **kwargs: Any) -> bytes: ... # noqa + + def safe_dump(data: Any, stream: Optional[Union[str, TextIO]] = None, **kwargs: Any # noqa ) -> Union[str, bytes]: """Same as yaml.safe_dump, but use fast C dumper if available. diff --git a/ops/testing.py b/ops/testing.py index cba75bba8..d92609bdd 100755 --- a/ops/testing.py +++ b/ops/testing.py @@ -789,11 +789,10 @@ def add_relation_unit(self, relation_id: int, remote_unit_name: str) -> None: self._backend._relation_data_raw[relation_id][remote_unit_name] = {} app = cast(model.Application, relation.app) # should not be None since we're testing if not remote_unit_name.startswith(app.name): - raise ValueError( + warnings.warn( 'Remote unit name invalid: the remote application of {} is called {!r}; ' 'the remote unit name should be {}/, not {!r}.' - ''.format(relation_name, app.name, - app.name, remote_unit_name)) + ''.format(relation_name, app.name, app.name, remote_unit_name)) app_and_units = self._backend._relation_app_and_units # pyright: ReportPrivateUsage=false app_and_units[relation_id]["units"].append(remote_unit_name) # Make sure that the Model reloads the relation_list for this relation_id, as well as