diff --git a/src/inline_snapshot/_adapter/value_adapter.py b/src/inline_snapshot/_adapter/value_adapter.py index f44d2358..ce58c4a8 100644 --- a/src/inline_snapshot/_adapter/value_adapter.py +++ b/src/inline_snapshot/_adapter/value_adapter.py @@ -1,9 +1,13 @@ from __future__ import annotations +import ast +import warnings + from inline_snapshot._code_repr import value_code_repr from inline_snapshot._unmanaged import Unmanaged from inline_snapshot._unmanaged import update_allowed from inline_snapshot._utils import value_to_token +from inline_snapshot.syntax_warnings import InlineSnapshotInfo from .._change import Replace from .adapter import Adapter @@ -31,6 +35,16 @@ def assign(self, old_value, old_node, new_value): else: new_token = value_to_token(new_value) + if isinstance(old_node, ast.JoinedStr): + if not old_value == new_value: + warnings.warn_explicit( + f"inline-snapshot will be able to fix f-strings in the future.\nThe current string value is:\n {new_value!r}", + filename=self.context._source.filename, + lineno=old_node.lineno, + category=InlineSnapshotInfo, + ) + return old_value + if not old_value == new_value: flag = "fix" elif ( diff --git a/src/inline_snapshot/_inline_snapshot.py b/src/inline_snapshot/_inline_snapshot.py index 62dcfcf0..a8741fdf 100644 --- a/src/inline_snapshot/_inline_snapshot.py +++ b/src/inline_snapshot/_inline_snapshot.py @@ -33,10 +33,6 @@ from ._utils import value_to_token -class NotImplementedYet(Exception): - pass - - snapshots = {} # type: Dict[Tuple[int, int], SnapshotReference] _active = False @@ -54,10 +50,6 @@ def _return(result): return result -class InlineSnapshotSyntaxWarning(Warning): - pass - - class Flags: """ fix: the value needs to be changed to pass the tests @@ -140,10 +132,10 @@ def _visible_value(self): return self._old_value def _get_changes(self) -> Iterator[Change]: - raise NotImplementedYet() + raise NotImplementedError() def _new_code(self): - raise NotImplementedYet() + raise NotImplementedError() def __repr__(self): return repr(self._visible_value()) diff --git a/src/inline_snapshot/syntax_warnings.py b/src/inline_snapshot/syntax_warnings.py index 35dc21a0..a403ec16 100644 --- a/src/inline_snapshot/syntax_warnings.py +++ b/src/inline_snapshot/syntax_warnings.py @@ -1,2 +1,6 @@ class InlineSnapshotSyntaxWarning(Warning): pass + + +class InlineSnapshotInfo(Warning): + pass