From aea10e0a9b4e2333ca8ec45a7ef4471e64fc13a9 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Tue, 3 Jan 2023 10:10:09 +0100 Subject: [PATCH 1/3] API docs: be more explicit about driver factory parameters --- docs/source/api.rst | 2 +- src/neo4j/_async/driver.py | 16 ++++++++++++---- src/neo4j/_sync/driver.py | 16 ++++++++++++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index e522425fe..89f4c6399 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -16,7 +16,7 @@ The :class:`neo4j.Driver` construction is done via a ``classmethod`` on the :cla .. autoclass:: neo4j.GraphDatabase :members: bookmark_manager - .. method:: driver + .. automethod:: driver Driver creation example: diff --git a/src/neo4j/_async/driver.py b/src/neo4j/_async/driver.py index b60440ef4..9b4a1c9f3 100644 --- a/src/neo4j/_async/driver.py +++ b/src/neo4j/_async/driver.py @@ -121,12 +121,20 @@ def driver( else: @classmethod - def driver(cls, uri, *, auth=None, **config) -> AsyncDriver: + def driver( + cls, uri: str, *, + auth: t.Union[t.Tuple[t.Any, t.Any], Auth, None] = None, + **config + ) -> AsyncDriver: """Create a driver. - :param uri: the connection URI for the driver, see :ref:`async-uri-ref` for available URIs. - :param auth: the authentication details, see :ref:`auth-ref` for available authentication details. - :param config: driver configuration key-word arguments, see :ref:`async-driver-configuration-ref` for available key-word arguments. + :param uri: the connection URI for the driver, + see :ref:`async-uri-ref` for available URIs. + :param auth: the authentication details, + see :ref:`auth-ref` for available authentication details. + :param config: driver configuration key-word arguments, + see :ref:`async-driver-configuration-ref` for available + key-word arguments. """ driver_type, security_type, parsed = parse_neo4j_uri(uri) diff --git a/src/neo4j/_sync/driver.py b/src/neo4j/_sync/driver.py index 5aace35b7..19a998467 100644 --- a/src/neo4j/_sync/driver.py +++ b/src/neo4j/_sync/driver.py @@ -118,12 +118,20 @@ def driver( else: @classmethod - def driver(cls, uri, *, auth=None, **config) -> Driver: + def driver( + cls, uri: str, *, + auth: t.Union[t.Tuple[t.Any, t.Any], Auth, None] = None, + **config + ) -> Driver: """Create a driver. - :param uri: the connection URI for the driver, see :ref:`uri-ref` for available URIs. - :param auth: the authentication details, see :ref:`auth-ref` for available authentication details. - :param config: driver configuration key-word arguments, see :ref:`driver-configuration-ref` for available key-word arguments. + :param uri: the connection URI for the driver, + see :ref:`uri-ref` for available URIs. + :param auth: the authentication details, + see :ref:`auth-ref` for available authentication details. + :param config: driver configuration key-word arguments, + see :ref:`driver-configuration-ref` for available + key-word arguments. """ driver_type, security_type, parsed = parse_neo4j_uri(uri) From cca4ab8967beeff0f4060d834812f24608726e17 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Tue, 3 Jan 2023 10:22:17 +0100 Subject: [PATCH 2/3] API docs: cannot combine +s/+ssc schemes with some settings --- docs/source/api.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/source/api.rst b/docs/source/api.rst index 89f4c6399..3ab576aa4 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -212,6 +212,8 @@ connection can be used to perform database related work. ------------- Specify whether to use an encrypted connection between the driver and server. +This setting is only available for URI schemes ``bolt`` and ``neo4j``. + This setting does not have any effect if a custom ``ssl_context`` is configured. :Type: ``bool`` @@ -312,6 +314,8 @@ For example: --------- Specify how to determine the authenticity of encryption certificates provided by the Neo4j instance on connection. +This setting is only available for URI schemes ``bolt`` and ``neo4j``. + This setting does not have any effect if ``encrypted`` is set to ``False``. :Type: ``neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES``, ``neo4j.TRUST_ALL_CERTIFICATES`` @@ -342,6 +346,8 @@ This setting does not have any effect if ``encrypted`` is set to ``False``. --------------- Specify a custom SSL context to use for wrapping connections. +This setting is only available for URI schemes ``bolt`` and ``neo4j``. + If given, ``encrypted`` and ``trusted_certificates`` have no effect. .. warning:: @@ -361,6 +367,8 @@ If given, ``encrypted`` and ``trusted_certificates`` have no effect. ------------------------ Specify how to determine the authenticity of encryption certificates provided by the Neo4j instance on connection. +This setting is only available for URI schemes ``bolt`` and ``neo4j``. + This setting does not have any effect if ``encrypted`` is set to ``False`` or a custom ``ssl_context`` is configured. From d3585d8bd08c1d42bdb46e686f62c537f44dadc5 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Tue, 3 Jan 2023 10:27:08 +0100 Subject: [PATCH 3/3] Minor tweak: add ref to URI when talking about schemes --- docs/source/api.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index 3ab576aa4..32965567d 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -212,7 +212,7 @@ connection can be used to perform database related work. ------------- Specify whether to use an encrypted connection between the driver and server. -This setting is only available for URI schemes ``bolt`` and ``neo4j``. +This setting is only available for URI schemes ``bolt://`` and ``neo4j://`` (:ref:`uri-ref`). This setting does not have any effect if a custom ``ssl_context`` is configured. @@ -314,7 +314,7 @@ For example: --------- Specify how to determine the authenticity of encryption certificates provided by the Neo4j instance on connection. -This setting is only available for URI schemes ``bolt`` and ``neo4j``. +This setting is only available for URI schemes ``bolt://`` and ``neo4j://`` (:ref:`uri-ref`). This setting does not have any effect if ``encrypted`` is set to ``False``. @@ -346,7 +346,7 @@ This setting does not have any effect if ``encrypted`` is set to ``False``. --------------- Specify a custom SSL context to use for wrapping connections. -This setting is only available for URI schemes ``bolt`` and ``neo4j``. +This setting is only available for URI schemes ``bolt://`` and ``neo4j://`` (:ref:`uri-ref`). If given, ``encrypted`` and ``trusted_certificates`` have no effect. @@ -367,7 +367,7 @@ If given, ``encrypted`` and ``trusted_certificates`` have no effect. ------------------------ Specify how to determine the authenticity of encryption certificates provided by the Neo4j instance on connection. -This setting is only available for URI schemes ``bolt`` and ``neo4j``. +This setting is only available for URI schemes ``bolt://`` and ``neo4j://`` (:ref:`uri-ref`). This setting does not have any effect if ``encrypted`` is set to ``False`` or a custom ``ssl_context`` is configured.