Skip to content

Commit d051616

Browse files
committed
Merge branch '6.x' into remove-read-write-transaction
2 parents cb0f68d + 0e4d772 commit d051616

35 files changed

+973
-1143
lines changed

CHANGELOG.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,49 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
5252
errors.
5353
- It is now the same error raised as when trying to start an explicit transaction while another explicit transaction
5454
is already active.
55+
- Slightly change `Neo4jError` and `ClientError`:
56+
- Properties `message` and `code` are always a `str` (instead of `str | None`).
57+
- Remove possibility to override/set `message` and `code` properties.
58+
- Remove undocumented, internal methods `Neo4jError.hydrate`, `Neo4jError.invalidates_all_connections`,
59+
and `Neo4jError.is_fatal_during_discovery`.
60+
- Remove deprecated method `Neo4jError.is_retriable`.
61+
Use `Neo4jError.is_retryable` instead.
62+
- Change string representation of `Neo4jError` to include GQL error information.
5563
- Remove deprecated `Record.__getslice__`. This magic method has been removed in Python 3.0.
5664
If you were calling it directly, please use `Record.__getitem__(slice(...))` or simply `record[...]` instead.
5765
- Remove deprecated class `neo4j.Bookmark` in favor of `neo4j.Bookmarks`.
5866
- Remove deprecated class `session.last_bookmark()` in favor of `last_bookmarks()`.
59-
- Make undocumented classes `ResolvedAddress`, `ResolvedIPv4Address`, and `ResolvedIPv6Address` private.
67+
- Remove deprecated driver configuration option `trust`.
68+
Use `trusted_certificates` instead.
69+
- Remove the associated constants `neo4j.TRUST_ALL_CERTIFICATES` and `neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES`.
6070
- Remove deprecated `session.read_transaction` and `session.write_transaction`.
6171
Instead, use `session.execute_read` and `session.execute_write` respectively.
72+
- Make undocumented classes `ResolvedAddress`, `ResolvedIPv4Address`, and `ResolvedIPv6Address` private.
73+
- Rework `PreviewWarning`.
74+
- Remove `ExperimentalWarning` and turn the few left instances of it into `PreviewWarning`.
75+
- Deprecate importing `PreviewWarning` from `neo4j`.
76+
Import it from `neo4j.warnings` instead.
77+
- Make undocumented internal constants private:
78+
- `neo4j.api`
79+
- `DRIVER_BOLT`
80+
- `DRIVER_NEO4J`
81+
- `SECURITY_TYPE_NOT_SECURE`
82+
- `SECURITY_TYPE_SECURE`
83+
- `SECURITY_TYPE_SELF_SIGNED_CERTIFICATE`
84+
- `neo4j.exceptions`
85+
- `CLASSIFICATION_CLIENT`
86+
- `CLASSIFICATION_DATABASE`
87+
- `CLASSIFICATION_TRANSIENT`
88+
- `ERROR_REWRITE_MAP`
89+
- `client_errors`
90+
- `transient_errors`
91+
- Raise `ConfigurationError` instead of ignoring the routing context (URI query parameters) when creating a direct
92+
driver ("bolt[+s[sc]]://" scheme).
93+
- Change behavior of closed drivers:
94+
- Raise `DriverError` on using the closed driver.
95+
- Calling `driver.close()` again is now a no-op.
96+
- No longer implicitly closing drivers and sessions in `__del__()` (finalizer/destructor).
97+
Make sure to call `.close()` on them explicitly or use them in a `with` statement.
6298

6399

64100
## Version 5.28

docs/source/api.rst

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ Closing a driver will immediately shut down all connections in the pool.
370370
:returns: the result of the ``result_transformer_``
371371
:rtype: T
372372

373+
:raises DriverError: if the driver has been closed.
374+
373375
.. versionadded:: 5.5
374376

375377
.. versionchanged:: 5.8
@@ -384,6 +386,9 @@ Closing a driver will immediately shut down all connections in the pool.
384386
The ``query_`` parameter now also accepts a :class:`.Query` object
385387
instead of only :class:`str`.
386388

389+
.. versionchanged:: 6.0
390+
Raise :exc:`DriverError` if the driver has been closed.
391+
387392

388393
.. _driver-configuration-ref:
389394

@@ -401,7 +406,6 @@ Additional configuration can be provided via the :class:`neo4j.Driver` construct
401406
+ :ref:`max-connection-pool-size-ref`
402407
+ :ref:`max-transaction-retry-time-ref`
403408
+ :ref:`resolver-ref`
404-
+ :ref:`trust-ref`
405409
+ :ref:`ssl-context-ref`
406410
+ :ref:`trusted-certificates-ref`
407411
+ :ref:`client-certificate-ref`
@@ -568,39 +572,6 @@ For example:
568572
:Default: :data:`None`
569573

570574

571-
.. _trust-ref:
572-
573-
``trust``
574-
---------
575-
Specify how to determine the authenticity of encryption certificates provided by the Neo4j instance on connection.
576-
577-
This setting is only available for URI schemes ``bolt://`` and ``neo4j://`` (:ref:`uri-ref`).
578-
579-
This setting does not have any effect if ``encrypted`` is set to ``False`` or a
580-
custom ``ssl_context`` is configured.
581-
582-
:Type: ``neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES``, ``neo4j.TRUST_ALL_CERTIFICATES``
583-
584-
.. py:attribute:: neo4j.TRUST_ALL_CERTIFICATES
585-
586-
Trust any server certificate (default). This ensures that communication
587-
is encrypted but does not verify the server certificate against a
588-
certificate authority. This option is primarily intended for use with
589-
the default auto-generated server certificate.
590-
591-
.. py:attribute:: neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES
592-
593-
Trust server certificates that can be verified against the system
594-
certificate authority. This option is primarily intended for use with
595-
full certificates.
596-
597-
:Default: ``neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES``.
598-
599-
.. deprecated:: 5.0
600-
This configuration option is deprecated and will be removed in a future
601-
release. Please use :ref:`trusted-certificates-ref` instead.
602-
603-
604575
.. _ssl-context-ref:
605576

606577
``ssl_context``
@@ -2217,9 +2188,9 @@ The Python Driver uses the built-in :class:`python:ResourceWarning` class to war
22172188
.. _development mode: https://docs.python.org/3/library/devmode.html#devmode
22182189

22192190

2220-
.. autoclass:: neo4j.PreviewWarning
2221-
2222-
.. autoclass:: neo4j.ExperimentalWarning
2191+
.. autoclass:: neo4j.warnings.PreviewWarning
2192+
:show-inheritance:
2193+
:members:
22232194

22242195
.. autoclass:: neo4j.warnings.Neo4jWarning
22252196
:show-inheritance:
@@ -2235,12 +2206,12 @@ The Python Driver uses the built-in :class:`python:ResourceWarning` class to war
22352206
Filtering Warnings
22362207
==================
22372208

2238-
This example shows how to suppress the :class:`neo4j.PreviewWarning` using the :func:`python:warnings.filterwarnings` function.
2209+
This example shows how to suppress the :class:`neo4j.warnings.PreviewWarning` using the :func:`python:warnings.filterwarnings` function.
22392210

22402211
.. code-block:: python
22412212
22422213
import warnings
2243-
from neo4j import PreviewWarning
2214+
from neo4j.warnings import PreviewWarning
22442215
22452216
...
22462217
@@ -2250,7 +2221,7 @@ This example shows how to suppress the :class:`neo4j.PreviewWarning` using the :
22502221
22512222
...
22522223
2253-
This will only mute the :class:`neo4j.PreviewWarning` for everything inside
2224+
This will only mute the :class:`neo4j.warnings.PreviewWarning` for everything inside
22542225
the ``with``-block. This is the preferred way to mute warnings, as warnings
22552226
triggerd by new code will still be visible.
22562227

@@ -2263,7 +2234,7 @@ following code:
22632234
.. code-block:: python
22642235
22652236
import warnings
2266-
from neo4j import PreviewWarning
2237+
from neo4j.warnings import PreviewWarning
22672238
22682239
warnings.filterwarnings("ignore", category=PreviewWarning)
22692240

docs/source/async_api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ Closing a driver will immediately shut down all connections in the pool.
352352
:returns: the result of the ``result_transformer_``
353353
:rtype: T
354354

355+
:raises DriverError: if the driver has been closed.
356+
355357
.. versionadded:: 5.5
356358

357359
.. versionchanged:: 5.8
@@ -366,6 +368,9 @@ Closing a driver will immediately shut down all connections in the pool.
366368
The ``query_`` parameter now also accepts a :class:`.Query` object
367369
instead of only :class:`str`.
368370

371+
.. versionchanged:: 6.0
372+
Raise :exc:`DriverError` if the driver has been closed.
373+
369374

370375
.. _async-driver-configuration-ref:
371376

src/neo4j/__init__.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@
4343
)
4444
from ._data import Record
4545
from ._meta import (
46-
ExperimentalWarning,
4746
get_user_agent,
48-
preview_warn as _preview_warn,
49-
PreviewWarning,
5047
version as __version__,
5148
)
5249
from ._sync.driver import (
@@ -61,6 +58,11 @@
6158
Session,
6259
Transaction,
6360
)
61+
from ._warnings import (
62+
deprecation_warn as _deprecation_warn,
63+
preview_warn as _preview_warn,
64+
PreviewWarning as _PreviewWarning,
65+
)
6466
from ._work import ( # noqa: F401 dynamic attribute
6567
EagerResult,
6668
GqlStatusObject as _GqlStatusObject,
@@ -80,6 +82,7 @@
8082
GqlStatusObject, # noqa: TCH004 false positive (dynamic attribute)
8183
NotificationClassification, # noqa: TCH004 false positive (dynamic attribute)
8284
)
85+
from ._warnings import PreviewWarning # noqa: TCH004 false positive (dynamic attribute)
8386

8487
from ._addressing import (
8588
Address,
@@ -100,8 +103,6 @@
100103
READ_ACCESS,
101104
ServerInfo,
102105
SYSTEM_DATABASE,
103-
TRUST_ALL_CERTIFICATES,
104-
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
105106
WRITE_ACCESS,
106107
)
107108

@@ -110,8 +111,6 @@
110111
"DEFAULT_DATABASE",
111112
"READ_ACCESS",
112113
"SYSTEM_DATABASE",
113-
"TRUST_ALL_CERTIFICATES",
114-
"TRUST_SYSTEM_CA_SIGNED_CERTIFICATES",
115114
"WRITE_ACCESS",
116115
"Address",
117116
"AsyncBoltDriver",
@@ -128,7 +127,6 @@
128127
"Bookmarks",
129128
"Driver",
130129
"EagerResult",
131-
"ExperimentalWarning",
132130
"GqlStatusObject",
133131
"GraphDatabase",
134132
"IPv4Address",
@@ -179,6 +177,14 @@ def __getattr__(name) -> _t.Any:
179177
stack_level=2,
180178
)
181179
return globals()[f"_{name}"]
180+
# TODO: 7.0 - remove this
181+
if name == "PreviewWarning":
182+
_deprecation_warn(
183+
f"Importing {name} from `neo4j` is deprecated and will be removed"
184+
f"in a future version. Import it from `neo4j.warnings` instead.",
185+
stack_level=2,
186+
)
187+
return _PreviewWarning
182188
raise AttributeError(f"module {__name__} has no attribute {name}")
183189

184190

src/neo4j/_api.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626

2727
__all__ = [
28+
"DRIVER_BOLT",
29+
"DRIVER_NEO4J",
30+
"SECURITY_TYPE_NOT_SECURE",
31+
"SECURITY_TYPE_SECURE",
32+
"SECURITY_TYPE_SELF_SIGNED_CERTIFICATE",
2833
"NotificationCategory",
2934
"NotificationClassification",
3035
"NotificationDisabledCategory",
@@ -36,6 +41,16 @@
3641
]
3742

3843

44+
DRIVER_BOLT: te.Final[str] = "DRIVER_BOLT"
45+
DRIVER_NEO4J: te.Final[str] = "DRIVER_NEO4J"
46+
47+
SECURITY_TYPE_NOT_SECURE: te.Final[str] = "SECURITY_TYPE_NOT_SECURE"
48+
SECURITY_TYPE_SELF_SIGNED_CERTIFICATE: te.Final[str] = (
49+
"SECURITY_TYPE_SELF_SIGNED_CERTIFICATE"
50+
)
51+
SECURITY_TYPE_SECURE: te.Final[str] = "SECURITY_TYPE_SECURE"
52+
53+
3954
class NotificationMinimumSeverity(str, Enum):
4055
"""
4156
Filter notifications returned by the server by minimum severity.

src/neo4j/_async/config.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121
from .._async_compat.concurrency import AsyncLock
2222
from .._conf import (
23-
_trust_to_trusted_certificates,
2423
Config,
25-
DeprecatedAlternative,
2624
TrustAll,
2725
TrustCustomCAs,
2826
TrustSystemCAs,
@@ -57,13 +55,6 @@ class AsyncPoolConfig(Config):
5755
# The maximum amount of time to wait for a TCP connection to be
5856
# established.
5957

60-
#: Trust
61-
trust = DeprecatedAlternative(
62-
"trusted_certificates", _trust_to_trusted_certificates
63-
)
64-
# Specify how to determine the authenticity of encryption certificates
65-
# provided by the Neo4j instance on connection.
66-
6758
#: Custom Resolver
6859
resolver = None
6960
# Custom resolver function, returning list of resolved addresses.

0 commit comments

Comments
 (0)