Skip to content

Commit f8143b2

Browse files
committed
Mark internals in driver.py with underscore
1 parent 67f073b commit f8143b2

File tree

3 files changed

+61
-71
lines changed

3 files changed

+61
-71
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
2222
- Remove deprecated exports from `neo4j`:
2323
- `log`, `Config`, `PoolConfig`, `SessionConfig`, `WorkspaceConfig` (internal - no replacement)
2424
- `SummaryNotificationPosition` (use `SummaryInputPosition` instead)
25-
- `api.Version` has been removed as it's unused now.
25+
- `api.Version` has been removed as it's unusedparse_target now.
2626
`ServerInfo.protocol_version` now is a `tuple[int, int]` insteadof a `api.Version`.
2727
This should be drop-in replacement is most cases:
2828
- `Version` was a sup-type of `tuple[int, int]`
@@ -56,6 +56,16 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
5656
If you were calling it directly, please use `Record.__getitem__(slice(...))` or simply `record[...]` instead.
5757
- Remove deprecated class `neo4j.Bookmark` in favor of `neo4j.Bookmarks`.
5858
- Remove deprecated class `session.last_bookmark()` in favor of `last_bookmarks()`.
59+
- Remove undocumented internals
60+
- `GraphDatabase`
61+
- `.bolt_driver`
62+
- `.neo4j_driver`
63+
- `BoltDriver` and `Neo4jDriver`
64+
- `.open`
65+
- `.parse_target`
66+
- `.default_host`
67+
- `.default_port`
68+
- `.default_target`
5969

6070

6171
## Version 5.28

src/neo4j/_async/driver.py

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,10 @@ def driver(
312312
# 'Routing parameters are not supported with scheme '
313313
# '"bolt". Given URI "{}".'.format(uri)
314314
# )
315-
return cls.bolt_driver(parsed.netloc, **config)
315+
return cls._bolt_driver(parsed.netloc, **config)
316316
# else driver_type == DRIVER_NEO4J
317317
routing_context = parse_routing_context(parsed.query)
318-
return cls.neo4j_driver(
318+
return cls._neo4j_driver(
319319
parsed.netloc, routing_context=routing_context, **config
320320
)
321321

@@ -404,7 +404,7 @@ def bookmark_manager(
404404
)
405405

406406
@classmethod
407-
def bolt_driver(cls, target, **config):
407+
def _bolt_driver(cls, target, **config):
408408
"""
409409
Create a direct driver.
410410
@@ -417,36 +417,28 @@ def bolt_driver(cls, target, **config):
417417
)
418418

419419
try:
420-
return AsyncBoltDriver.open(target, **config)
420+
return AsyncBoltDriver._open(target, **config)
421421
except (BoltHandshakeError, BoltSecurityError) as error:
422422
from ..exceptions import ServiceUnavailable
423423

424424
raise ServiceUnavailable(str(error)) from error
425425

426426
@classmethod
427-
def neo4j_driver(cls, *targets, routing_context=None, **config):
427+
def _neo4j_driver(cls, target, routing_context=None, **config):
428428
"""
429429
Create a routing driver.
430430
431431
Create a driver for routing-capable Neo4j service access
432432
that uses socket I/O and thread-based concurrency.
433433
"""
434-
# TODO: 6.0 - adjust signature to only take one target
435-
if len(targets) > 1:
436-
deprecation_warn(
437-
"Creating a routing driver with multiple targets is "
438-
"deprecated. The driver only uses the first target anyway. "
439-
"The method signature will change in a future release.",
440-
)
441-
442434
from .._exceptions import (
443435
BoltHandshakeError,
444436
BoltSecurityError,
445437
)
446438

447439
try:
448-
return AsyncNeo4jDriver.open(
449-
*targets, routing_context=routing_context, **config
440+
return AsyncNeo4jDriver._open(
441+
target, routing_context=routing_context, **config
450442
)
451443
except (BoltHandshakeError, BoltSecurityError) as error:
452444
from ..exceptions import ServiceUnavailable
@@ -455,10 +447,9 @@ def neo4j_driver(cls, *targets, routing_context=None, **config):
455447

456448

457449
class _Direct:
458-
# TODO: 6.0 - those attributes should be private
459-
default_host = "localhost"
460-
default_port = 7687
461-
default_target = ":"
450+
_default_host = "localhost"
451+
_default_port = 7687
452+
_default_target = ":"
462453

463454
def __init__(self, address):
464455
self._address = address
@@ -468,22 +459,21 @@ def address(self):
468459
return self._address
469460

470461
@classmethod
471-
def parse_target(cls, target):
462+
def _parse_target(cls, target):
472463
"""Parse a target string to produce an address."""
473464
if not target:
474-
target = cls.default_target
465+
target = cls._default_target
475466
return Address.parse(
476467
target,
477-
default_host=cls.default_host,
478-
default_port=cls.default_port,
468+
default_host=cls._default_host,
469+
default_port=cls._default_port,
479470
)
480471

481472

482473
class _Routing:
483-
# TODO: 6.0 - those attributes should be private
484-
default_host = "localhost"
485-
default_port = 7687
486-
default_targets = ": :17601 :17687"
474+
_default_host = "localhost"
475+
_default_port = 7687
476+
_default_targets = ": :17601 :17687"
487477

488478
def __init__(self, initial_addresses):
489479
self._initial_addresses = initial_addresses
@@ -493,15 +483,15 @@ def initial_addresses(self):
493483
return self._initial_addresses
494484

495485
@classmethod
496-
def parse_targets(cls, *targets):
486+
def _parse_targets(cls, *targets):
497487
"""Parse a sequence of target strings to produce an address list."""
498488
targets = " ".join(targets)
499489
if not targets:
500-
targets = cls.default_targets
490+
targets = cls._default_targets
501491
return Address.parse_list(
502492
targets,
503-
default_host=cls.default_host,
504-
default_port=cls.default_port,
493+
default_host=cls._default_host,
494+
default_port=cls._default_port,
505495
)
506496

507497

@@ -1331,10 +1321,10 @@ class AsyncBoltDriver(_Direct, AsyncDriver):
13311321
"""
13321322

13331323
@classmethod
1334-
def open(cls, target, **config):
1324+
def _open(cls, target, **config):
13351325
from .io import AsyncBoltPool
13361326

1337-
address = cls.parse_target(target)
1327+
address = cls._parse_target(target)
13381328
pool_config, default_workspace_config = Config.consume_chain(
13391329
config, AsyncPoolConfig, WorkspaceConfig
13401330
)
@@ -1365,10 +1355,10 @@ class AsyncNeo4jDriver(_Routing, AsyncDriver):
13651355
"""
13661356

13671357
@classmethod
1368-
def open(cls, *targets, routing_context=None, **config):
1358+
def _open(cls, *targets, routing_context=None, **config):
13691359
from .io import AsyncNeo4jPool
13701360

1371-
addresses = cls.parse_targets(*targets)
1361+
addresses = cls._parse_targets(*targets)
13721362
pool_config, default_workspace_config = Config.consume_chain(
13731363
config, AsyncPoolConfig, WorkspaceConfig
13741364
)

src/neo4j/_sync/driver.py

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

0 commit comments

Comments
 (0)