Skip to content

Commit 484b1d9

Browse files
committed
Merge branch '6.x' into mark-imports-private
2 parents 597435c + 273194e commit 484b1d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1107
-817
lines changed

CHANGELOG.md

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,24 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
5757
- Remove possibility to override/set `message` and `code` properties.
5858
- Remove undocumented, internal methods `Neo4jError.hydrate`, `Neo4jError.invalidates_all_connections`,
5959
and `Neo4jError.is_fatal_during_discovery`.
60-
- Remove deprecated method `Neo4jError.is_retriable`.
60+
- Remove deprecated method `Neo4jError.is_retriable`.
6161
Use `Neo4jError.is_retryable` instead.
6262
- Change string representation of `Neo4jError` to include GQL error information.
6363
- Remove deprecated `Record.__getslice__`. This magic method has been removed in Python 3.0.
6464
If you were calling it directly, please use `Record.__getitem__(slice(...))` or simply `record[...]` instead.
65-
- Remove deprecated class `neo4j.Bookmark` in favor of `neo4j.Bookmarks`.
66-
- Remove deprecated class `session.last_bookmark()` in favor of `last_bookmarks()`.
65+
- Bookmarks
66+
- Remove deprecated class `neo4j.Bookmark` in favor of `neo4j.Bookmarks`.
67+
- Remove deprecated class `session.last_bookmark()` in favor of `last_bookmarks()`.
68+
- Deprecate passing raw sting bookmarks as `initial_bookmarks` to `GraphDatabase.bookmark_manager()`.
69+
Use a `neo4j.Bookmarks` object instead.
70+
- `Driver.session()` no longer accepts raw string bookmarks as `bookmarks` argument.
71+
Use a `neo4j.Bookmarks` object instead.
72+
- Remove deprecated `ServerInfo.connection_id`.
73+
There is no replacement as this is considered internal information.
6774
- Remove deprecated driver configuration option `trust`.
6875
Use `trusted_certificates` instead.
6976
- Remove the associated constants `neo4j.TRUST_ALL_CERTIFICATES` and `neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES`.
70-
- Remove deprecated `session.read_transaction` and `session.write_transaction`.
77+
- Remove deprecated `session.read_transaction` and `session.write_transaction`.
7178
Instead, use `session.execute_read` and `session.execute_write` respectively.
7279
- Make undocumented classes `ResolvedAddress`, `ResolvedIPv4Address`, and `ResolvedIPv6Address` private.
7380
- Rework `PreviewWarning`.
@@ -92,6 +99,23 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
9299
- `client_errors`
93100
- `transient_errors`
94101
- all other indirectly exposed items from imports (e.g. `typing` as `neo4j.exceptions.t`)
102+
- `neo4j.time`
103+
- `DATE_ISO_PATTERN`
104+
- `TIME_ISO_PATTERN`
105+
- `DURATION_ISO_PATTERN`
106+
- `NANO_SECONDS`
107+
- `AVERAGE_SECONDS_IN_MONTH`
108+
- `AVERAGE_SECONDS_IN_DAY`
109+
- `FORMAT_F_REPLACE`
110+
- `IS_LEAP_YEAR`
111+
- `DAYS_IN_YEAR`
112+
- `DAYS_IN_MONTH`
113+
- `round_half_to_even`
114+
- `symmetric_divmod`
115+
- `DateTimeType`
116+
- `DateType`
117+
- `TimeType`
118+
- all other indirectly exposed items from imports (e.g. `re` as `neo4j.time.re`)
95119
- `neo4j.spatial`
96120
- `hydrate_point`
97121
- `dehydrate_point`
@@ -107,12 +131,26 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
107131
- `.default_target`
108132
- `neo4j.graph`, `neo4j.addressing`, `neo4j.api`
109133
- indirectly exposed items from imports (e.g. `collections.abc.Mapping` as `neo4j.graph.Mapping`).
134+
- `BoltDriver` and `Neo4jDriver`
135+
- `.open`
136+
- `.parse_target`
137+
- `.default_host`
138+
- `.default_port`
139+
- `.default_target`
140+
- `neo4j.debug`
141+
- `ColourFormatter`
142+
- `TaskIdFilter`
143+
- all other indirectly exposed items from imports (e.g. `asyncio` as `neo4j.debug.asyncio`)
144+
- Deprecate ClockTime and its accessors
145+
- For each `neo4j.time.Date`, `neo4j.time.DateTime`, `neo4j.time.Time`
146+
- `from_clock_time` and `to_clock_time` methods
147+
- `neo4j.time.ClockTime` itself
110148
- Raise `ConfigurationError` instead of ignoring the routing context (URI query parameters) when creating a direct
111149
driver ("bolt[+s[sc]]://" scheme).
112150
- Change behavior of closed drivers:
113-
- Raise `DriverError` on using the closed driver.
114-
- Calling `driver.close()` again is now a no-op.
115-
- No longer implicitly closing drivers and sessions in `__del__()` (finalizer/destructor).
151+
- Raise `DriverError` on using the closed driver.
152+
- Calling `driver.close()` again is now a no-op.
153+
- No longer implicitly closing drivers and sessions in `__del__()` (finalizer/destructor).
116154
Make sure to call `.close()` on them explicitly or use them in a `with` statement.
117155
- Make `Summary.summary_notifications` a `tuple` instead of a `list` and type it with `Sequence` to signify that it
118156
should be treated as immutable.
@@ -235,17 +273,17 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
235273
manager related methods:
236274
- `neo4j.BookmarkManger` and `neo4j.AsyncBookmarkManger` abstract base
237275
classes:
238-
- ``update_bookmarks`` has no longer a ``database`` argument.
239-
- ``get_bookmarks`` has no longer a ``database`` argument.
240-
- The ``get_all_bookmarks`` method was removed.
241-
- The ``forget`` method was removed.
276+
- `update_bookmarks` has no longer a `database` argument.
277+
- `get_bookmarks` has no longer a `database` argument.
278+
- The `get_all_bookmarks` method was removed.
279+
- The `forget` method was removed.
242280
- `neo4j.GraphDatabase.bookmark_manager` and
243281
`neo4j.AsyncGraphDatabase.bookmark_manager` factory methods:
244-
- ``initial_bookmarks`` is no longer a mapping from database name
282+
- `initial_bookmarks` is no longer a mapping from database name
245283
to bookmarks but plain bookmarks.
246-
- ``bookmarks_supplier`` no longer receives the database name as
284+
- `bookmarks_supplier` no longer receives the database name as
247285
an argument.
248-
- ``bookmarks_consumer`` no longer receives the database name as
286+
- `bookmarks_consumer` no longer receives the database name as
249287
an argument.
250288

251289

benchkit/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from contextlib import contextmanager
2121
from multiprocessing import Semaphore
2222

23-
import typing_extensions as te
2423
from sanic import Sanic
2524
from sanic.exceptions import (
2625
BadRequest,
@@ -43,7 +42,7 @@
4342
from .workloads import Workload
4443

4544

46-
T_App: te.TypeAlias = "Sanic[Config, BenchKitContext]"
45+
T_App: t.TypeAlias = "Sanic[Config, BenchKitContext]"
4746

4847

4948
def create_app() -> T_App:

benchkit/workloads.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
import asyncio
2020
import enum
2121
import typing as t
22+
from collections.abc import (
23+
Iterable,
24+
Iterator,
25+
Mapping,
26+
)
2227
from dataclasses import dataclass
2328

24-
import typing_extensions as te
25-
2629

2730
if t.TYPE_CHECKING:
28-
from collections.abc import Iterator
31+
import typing_extensions as te
2932

3033
from neo4j import (
3134
AsyncDriver,
@@ -40,7 +43,7 @@
4043
]
4144

4245

43-
class Workloads(t.Mapping):
46+
class Workloads(Mapping):
4447
def __init__(self) -> None:
4548
self._workloads: dict[str, Workload] = {}
4649
self._current_id: int = 0
@@ -517,7 +520,7 @@ class _WorkloadQuery:
517520

518521
@classmethod
519522
def parse_multiple(cls, queries: t.Any) -> list[te.Self]:
520-
if not isinstance(queries, t.Iterable):
523+
if not isinstance(queries, Iterable):
521524
raise TypeError("Workload queries must be a list")
522525
return [cls.parse(query) for query in queries]
523526

@@ -544,7 +547,7 @@ def parse(cls, query: t.Any) -> te.Self:
544547
@dataclass
545548
class _WorkloadConfig:
546549
database: str | None
547-
routing: te.Literal["r", "w"]
550+
routing: t.Literal["r", "w"]
548551

549552
@classmethod
550553
def parse(cls, data: t.Any) -> te.Self:
@@ -554,7 +557,7 @@ def parse(cls, data: t.Any) -> te.Self:
554557
if not isinstance(database, str):
555558
raise TypeError("Workload database must be a string")
556559

557-
routing: te.Literal["r", "w"] = "w"
560+
routing: t.Literal["r", "w"] = "w"
558561
if "routing" in data:
559562
raw_routing = data["routing"]
560563
if not isinstance(routing, str):

docs/source/conf.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import os
1919
import sys
20-
import typing
2120

2221

2322
# If extensions (or modules to document with autodoc) are in another directory,
@@ -123,17 +122,7 @@
123122
# Don't include type hints in function signatures
124123
autodoc_typehints = "description"
125124

126-
autodoc_type_aliases = {
127-
# The code-base uses `import typing_extensions as te`.
128-
# Re-write these to use `typing` instead, as Sphinx always resolves against
129-
# the latest version of the `typing` module.
130-
# This is a work-around to make Sphinx resolve type hints correctly, even
131-
# though we're using `from __future__ import annotations`.
132-
"te": typing,
133-
# Type alias that's only defined and imported if `typing.TYPE_CHECKING`
134-
# is `True`.
135-
"_TAuth": "typing.Tuple[typing.Any, typing.Any] | Auth | None",
136-
}
125+
autodoc_type_aliases = {}
137126

138127
# -- Options for HTML output ----------------------------------------------
139128
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ extend-exclude = [
139139

140140
[tool.ruff.lint]
141141
preview = true # to get CPY lints
142+
typing-modules = ["neo4j._typing"]
142143
extend-ignore = [
143144
"RUF002", # allow ’ (RIGHT SINGLE QUOTATION MARK) to be used as an apostrophe (e.g. "it’s")
144145

src/neo4j/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
# limitations under the License.
1515

1616

17-
import typing as _t
18-
17+
from . import _typing as _t
1918
from ._api import ( # noqa: F401 dynamic attributes
2019
NotificationCategory,
2120
NotificationDisabledCategory,

src/neo4j/_addressing.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from __future__ import annotations
1818

19-
import typing as t
2019
from contextlib import suppress as _suppress
2120
from socket import (
2221
AddressFamily,
@@ -25,17 +24,15 @@
2524
getservbyname,
2625
)
2726

28-
29-
if t.TYPE_CHECKING:
30-
import typing_extensions as te
27+
from . import _typing as t
3128

3229

3330
_T = t.TypeVar("_T")
3431

3532

3633
if t.TYPE_CHECKING:
3734

38-
class _WithPeerName(te.Protocol):
35+
class _WithPeerName(t.Protocol):
3936
def getpeername(self) -> tuple: ...
4037

4138

src/neo4j/_api.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,19 @@
1616

1717
from __future__ import annotations
1818

19-
import typing as t
2019
from enum import Enum
2120
from urllib.parse import (
2221
parse_qs,
2322
urlparse,
2423
)
2524

26-
from . import api
25+
from . import (
26+
_typing as t,
27+
api,
28+
)
2729
from .exceptions import ConfigurationError
2830

2931

30-
if t.TYPE_CHECKING:
31-
import typing_extensions as te
32-
33-
3432
__all__ = [
3533
"DRIVER_BOLT",
3634
"DRIVER_NEO4J",
@@ -51,14 +49,14 @@
5149
]
5250

5351

54-
DRIVER_BOLT: te.Final[str] = "DRIVER_BOLT"
55-
DRIVER_NEO4J: te.Final[str] = "DRIVER_NEO4J"
52+
DRIVER_BOLT: t.Final[str] = "DRIVER_BOLT"
53+
DRIVER_NEO4J: t.Final[str] = "DRIVER_NEO4J"
5654

57-
SECURITY_TYPE_NOT_SECURE: te.Final[str] = "SECURITY_TYPE_NOT_SECURE"
58-
SECURITY_TYPE_SELF_SIGNED_CERTIFICATE: te.Final[str] = (
55+
SECURITY_TYPE_NOT_SECURE: t.Final[str] = "SECURITY_TYPE_NOT_SECURE"
56+
SECURITY_TYPE_SELF_SIGNED_CERTIFICATE: t.Final[str] = (
5957
"SECURITY_TYPE_SELF_SIGNED_CERTIFICATE"
6058
)
61-
SECURITY_TYPE_SECURE: te.Final[str] = "SECURITY_TYPE_SECURE"
59+
SECURITY_TYPE_SECURE: t.Final[str] = "SECURITY_TYPE_SECURE"
6260

6361

6462
def parse_neo4j_uri(uri):
@@ -184,7 +182,7 @@ class NotificationMinimumSeverity(str, Enum):
184182
if t.TYPE_CHECKING:
185183
T_NotificationMinimumSeverity = (
186184
NotificationMinimumSeverity
187-
| te.Literal[
185+
| t.Literal[
188186
"OFF",
189187
"WARNING",
190188
"INFORMATION",
@@ -331,7 +329,7 @@ class NotificationDisabledClassification(str, Enum):
331329
T_NotificationDisabledCategory = (
332330
NotificationDisabledCategory
333331
| NotificationDisabledClassification
334-
| te.Literal[
332+
| t.Literal[
335333
"HINT",
336334
"UNRECOGNIZED",
337335
"UNSUPPORTED",
@@ -458,5 +456,5 @@ class TelemetryAPI(int, Enum):
458456

459457

460458
if t.TYPE_CHECKING:
461-
T_RoutingControl = RoutingControl | te.Literal["r", "w"]
459+
T_RoutingControl = RoutingControl | t.Literal["r", "w"]
462460
__all__.append("T_RoutingControl")

src/neo4j/_async/_debug/_concurrency_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
import inspect
2020
import traceback
21-
import typing as t
2221
from copy import deepcopy
2322
from functools import wraps
2423

24+
from ... import _typing as t
2525
from ..._async_compat.concurrency import (
2626
AsyncLock,
2727
AsyncRLock,

src/neo4j/_async/auth_management.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
from __future__ import annotations
1818

1919
import abc
20-
import typing as t
2120
from logging import getLogger
2221

22+
from .. import _typing as t
2323
from .._async_compat.concurrency import (
2424
AsyncCooperativeLock,
2525
AsyncLock,
@@ -32,9 +32,11 @@
3232
ExpiringAuth,
3333
)
3434

35+
# ignore TCH001 to make sphinx not completely drop the ball
36+
from ..api import _TAuth # noqa: TCH001
37+
3538

3639
if t.TYPE_CHECKING:
37-
from ..api import _TAuth
3840
from ..exceptions import Neo4jError
3941

4042

0 commit comments

Comments
 (0)