Skip to content

Commit 07f3e5e

Browse files
committed
Remove Bookmark in favor or Bookmarks
1 parent 7b07121 commit 07f3e5e

File tree

10 files changed

+14
-253
lines changed

10 files changed

+14
-253
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
4040
- `connection_acquisition_timeout` configuration option
4141
- `ValueError` on invalid values (instead of `ClientError`)
4242
- Consistently restrict the value to be strictly positive
43+
- Remove deprecated class `neo4j.Bookmark` in favor of `neo4j.Bookmarks`.
4344

4445

4546
## Version 5.28

docs/source/api.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,18 @@ Optional :class:`neo4j.Bookmarks`. Use this to causally chain sessions.
984984
See :meth:`.Session.last_bookmarks` or :meth:`.AsyncSession.last_bookmarks` for
985985
more information.
986986

987+
:Type: ``None``, ``neo4j.Bookmarks``
988+
987989
:Default: :data:`None`
988990

989991
.. deprecated:: 5.0
990992
Alternatively, an iterable of strings can be passed. This usage is
991993
deprecated and will be removed in a future release. Please use a
992994
:class:`neo4j.Bookmarks` object instead.
993995

996+
.. versionchanged:: 6.0
997+
Only accepts :class:`neo4j.Bookmarks` objects or :data:`None`.
998+
994999

9951000
.. _database-ref:
9961001

@@ -1940,9 +1945,6 @@ Bookmarks
19401945
:members:
19411946
:special-members: __bool__, __add__, __iter__
19421947

1943-
.. autoclass:: neo4j.Bookmark
1944-
:members:
1945-
19461948

19471949
BookmarkManager
19481950
===============

src/neo4j/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
AuthToken,
9494
basic_auth,
9595
bearer_auth,
96-
Bookmark,
9796
Bookmarks,
9897
custom_auth,
9998
DEFAULT_DATABASE,
@@ -126,7 +125,6 @@
126125
"Auth",
127126
"AuthToken",
128127
"BoltDriver",
129-
"Bookmark",
130128
"Bookmarks",
131129
"Driver",
132130
"EagerResult",

src/neo4j/_async/work/workspace.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,13 @@ def _set_pinned_database(self, database):
127127
self._config.database = database
128128

129129
def _initialize_bookmarks(self, bookmarks):
130-
if isinstance(bookmarks, Bookmarks):
131-
prepared_bookmarks = tuple(bookmarks.raw_values)
132-
elif hasattr(bookmarks, "__iter__"):
133-
deprecation_warn(
134-
"Passing an iterable as `bookmarks` to `Session` is "
135-
"deprecated. Please use a `Bookmarks` instance.",
136-
stack_level=5,
137-
)
138-
prepared_bookmarks = tuple(bookmarks)
139-
elif not bookmarks:
130+
if bookmarks is None:
140131
prepared_bookmarks = ()
132+
elif isinstance(bookmarks, Bookmarks):
133+
prepared_bookmarks = tuple(bookmarks.raw_values)
141134
else:
142135
raise TypeError(
143-
"Bookmarks must be an instance of Bookmarks or an "
144-
"iterable of raw bookmarks (deprecated)."
136+
"Bookmarks must be an instance of Bookmarks or None."
145137
)
146138
self._initial_bookmarks = self._bookmarks = prepared_bookmarks
147139

src/neo4j/_sync/work/workspace.py

Lines changed: 4 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/neo4j/api.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"AsyncBookmarkManager",
6666
"Auth",
6767
"AuthToken",
68-
"Bookmark",
6968
"BookmarkManager",
7069
"Bookmarks",
7170
"ServerInfo",
@@ -234,51 +233,6 @@ def custom_auth(
234233
return Auth(scheme, principal, credentials, realm, **parameters)
235234

236235

237-
# TODO: 6.0 - remove this class
238-
@deprecated("Use the `Bookmarks` class instead.")
239-
class Bookmark:
240-
"""
241-
A Bookmark object contains an immutable list of bookmark string values.
242-
243-
:param values: ASCII string values
244-
245-
.. deprecated:: 5.0
246-
`Bookmark` will be removed in version 6.0.
247-
Use :class:`Bookmarks` instead.
248-
"""
249-
250-
def __init__(self, *values: str) -> None:
251-
if values:
252-
bookmarks = []
253-
for ix in values:
254-
try:
255-
if ix:
256-
ix.encode("ascii")
257-
bookmarks.append(ix)
258-
except UnicodeEncodeError as e:
259-
raise ValueError(f"The value {ix} is not ASCII") from e
260-
self._values = frozenset(bookmarks)
261-
else:
262-
self._values = frozenset()
263-
264-
def __repr__(self) -> str:
265-
"""
266-
Represent the container as str.
267-
268-
:returns: repr string with sorted values
269-
"""
270-
values = ", ".join([f"'{ix}'" for ix in sorted(self._values)])
271-
return f"<Bookmark values={{{values}}}>"
272-
273-
def __bool__(self) -> bool:
274-
return bool(self._values)
275-
276-
@property
277-
def values(self) -> frozenset:
278-
""":returns: immutable list of bookmark string values"""
279-
return self._values
280-
281-
282236
class Bookmarks:
283237
"""
284238
Container for an immutable set of bookmark string values.

tests/unit/async_/work/test_session.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,6 @@ async def test_session_last_bookmark_is_deprecated(async_fake_pool, bookmarks):
242242
assert (await session.last_bookmark()) is None
243243

244244

245-
@pytest.mark.parametrize(
246-
"bookmarks", (("foo",), ("foo", "bar"), (), ["foo", "bar"], {"a", "b"})
247-
)
248-
@mark_async_test
249-
async def test_session_bookmarks_as_iterable_is_deprecated(
250-
async_fake_pool, bookmarks
251-
):
252-
with pytest.warns(DeprecationWarning):
253-
async with AsyncSession(
254-
async_fake_pool, SessionConfig(bookmarks=bookmarks)
255-
) as session:
256-
ret_bookmarks = (await session.last_bookmarks()).raw_values
257-
assert ret_bookmarks == frozenset(bookmarks)
258-
259-
260245
@pytest.mark.parametrize(
261246
("query", "error_type"),
262247
(

tests/unit/common/test_api.py

Lines changed: 0 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -28,145 +28,6 @@
2828
standard_ascii = [chr(i) for i in range(128)]
2929
not_ascii = "♥O◘♦♥O◘♦"
3030

31-
32-
def test_bookmark_is_deprecated() -> None:
33-
with pytest.deprecated_call():
34-
neo4j.Bookmark()
35-
36-
37-
def test_bookmark_initialization_with_no_values() -> None:
38-
with pytest.deprecated_call():
39-
bookmark = neo4j.Bookmark()
40-
assert bookmark.values == frozenset()
41-
assert bool(bookmark) is False
42-
assert repr(bookmark) == "<Bookmark values={}>"
43-
44-
45-
@pytest.mark.parametrize(
46-
("test_input", "expected_values", "expected_bool", "expected_repr"),
47-
[
48-
(
49-
(None,),
50-
frozenset(),
51-
False,
52-
"<Bookmark values={}>",
53-
),
54-
(
55-
(None, None),
56-
frozenset(),
57-
False,
58-
"<Bookmark values={}>",
59-
),
60-
(
61-
("bookmark1", None),
62-
frozenset({"bookmark1"}),
63-
True,
64-
"<Bookmark values={'bookmark1'}>",
65-
),
66-
(
67-
("bookmark1", None, "bookmark2", None),
68-
frozenset({"bookmark1", "bookmark2"}),
69-
True,
70-
"<Bookmark values={'bookmark1', 'bookmark2'}>",
71-
),
72-
(
73-
(None, "bookmark1", None, "bookmark2", None, None, "bookmark3"),
74-
frozenset({"bookmark1", "bookmark2", "bookmark3"}),
75-
True,
76-
"<Bookmark values={'bookmark1', 'bookmark2', 'bookmark3'}>",
77-
),
78-
],
79-
)
80-
def test_bookmark_initialization_with_values_none(
81-
test_input, expected_values, expected_bool, expected_repr
82-
) -> None:
83-
with pytest.deprecated_call():
84-
bookmark = neo4j.Bookmark(*test_input)
85-
assert bookmark.values == expected_values
86-
assert bool(bookmark) is expected_bool
87-
assert repr(bookmark) == expected_repr
88-
89-
90-
@pytest.mark.parametrize(
91-
("test_input", "expected_values", "expected_bool", "expected_repr"),
92-
[
93-
(
94-
("",),
95-
frozenset(),
96-
False,
97-
"<Bookmark values={}>",
98-
),
99-
(
100-
("", ""),
101-
frozenset(),
102-
False,
103-
"<Bookmark values={}>",
104-
),
105-
(
106-
("bookmark1", ""),
107-
frozenset({"bookmark1"}),
108-
True,
109-
"<Bookmark values={'bookmark1'}>",
110-
),
111-
(
112-
("bookmark1", "", "bookmark2", ""),
113-
frozenset({"bookmark1", "bookmark2"}),
114-
True,
115-
"<Bookmark values={'bookmark1', 'bookmark2'}>",
116-
),
117-
(
118-
("", "bookmark1", "", "bookmark2", "", "", "bookmark3"),
119-
frozenset({"bookmark1", "bookmark2", "bookmark3"}),
120-
True,
121-
"<Bookmark values={'bookmark1', 'bookmark2', 'bookmark3'}>",
122-
),
123-
],
124-
)
125-
def test_bookmark_initialization_with_values_empty_string(
126-
test_input, expected_values, expected_bool, expected_repr
127-
) -> None:
128-
with pytest.deprecated_call():
129-
bookmark = neo4j.Bookmark(*test_input)
130-
assert bookmark.values == expected_values
131-
assert bool(bookmark) is expected_bool
132-
assert repr(bookmark) == expected_repr
133-
134-
135-
@pytest.mark.parametrize(
136-
("test_input", "expected_values", "expected_bool", "expected_repr"),
137-
[
138-
(
139-
("bookmark1",),
140-
frozenset({"bookmark1"}),
141-
True,
142-
"<Bookmark values={'bookmark1'}>",
143-
),
144-
(
145-
("bookmark1", "bookmark2", "bookmark3"),
146-
frozenset({"bookmark1", "bookmark2", "bookmark3"}),
147-
True,
148-
"<Bookmark values={'bookmark1', 'bookmark2', 'bookmark3'}>",
149-
),
150-
(
151-
standard_ascii,
152-
frozenset(standard_ascii),
153-
True,
154-
"<Bookmark values={{'{values}'}}>".format(
155-
values="', '".join(standard_ascii)
156-
),
157-
),
158-
],
159-
)
160-
def test_bookmark_initialization_with_valid_strings(
161-
test_input, expected_values, expected_bool, expected_repr
162-
) -> None:
163-
with pytest.deprecated_call():
164-
bookmark = neo4j.Bookmark(*test_input)
165-
assert bookmark.values == expected_values
166-
assert bool(bookmark) is expected_bool
167-
assert repr(bookmark) == expected_repr
168-
169-
17031
_bm_input_mark = pytest.mark.parametrize(
17132
("test_input", "expected"),
17233
[
@@ -177,14 +38,6 @@ def test_bookmark_initialization_with_valid_strings(
17738
)
17839

17940

180-
@_bm_input_mark
181-
def test_bookmark_initialization_with_invalid_strings(
182-
test_input: tuple[str], expected
183-
) -> None:
184-
with pytest.raises(expected), pytest.warns(DeprecationWarning):
185-
neo4j.Bookmark(*test_input)
186-
187-
18841
@_bm_input_mark
18942
def test_bookmarks_initialization_with_invalid_strings(
19043
test_input: tuple[str], expected

tests/unit/common/test_import_neo4j.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def test_import_neo4j():
4343
("basic_auth", None),
4444
("bearer_auth", None),
4545
("BoltDriver", None),
46-
("Bookmark", None),
4746
("Bookmarks", None),
4847
("custom_auth", None),
4948
("DEFAULT_DATABASE", None),

tests/unit/sync/work/test_session.py

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)