Skip to content

Commit 5b53d72

Browse files
authored
Merge pull request #1195 from robsdedude/mark-imports-private
Mark indirectly exposed items from imports as private (e.g. `collections.abc.Mapping` as `neo4j.graph.Mapping`). Affected packages/modules: * `neo4j.exceptions` * `neo4j.graph` * `neo4j.addressing` * `neo4j.api`.
2 parents 273194e + 484b1d9 commit 5b53d72

File tree

5 files changed

+38
-33
lines changed

5 files changed

+38
-33
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
9898
- `ERROR_REWRITE_MAP`
9999
- `client_errors`
100100
- `transient_errors`
101+
- all other indirectly exposed items from imports (e.g. `typing` as `neo4j.exceptions.t`)
101102
- `neo4j.time`
102103
- `DATE_ISO_PATTERN`
103104
- `TIME_ISO_PATTERN`
@@ -128,6 +129,8 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
128129
- `.default_host`
129130
- `.default_port`
130131
- `.default_target`
132+
- `neo4j.graph`, `neo4j.addressing`, `neo4j.api`
133+
- indirectly exposed items from imports (e.g. `collections.abc.Mapping` as `neo4j.graph.Mapping`).
131134
- `BoltDriver` and `Neo4jDriver`
132135
- `.open`
133136
- `.parse_target`

src/neo4j/addressing.py

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

1616

17-
from __future__ import annotations
17+
from __future__ import annotations as _
1818

1919
from ._addressing import (
2020
Address,

src/neo4j/api.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616

1717
"""Base classes and helpers."""
1818

19-
from __future__ import annotations
19+
from __future__ import annotations as _
2020

21-
import abc
21+
import abc as _abc
2222

2323
from . import _typing as _t
2424

25+
# ignore TCH001 to make sphinx not completely drop the ball
26+
from ._addressing import Address as _Address # noqa: TCH001
27+
2528

2629
if _t.TYPE_CHECKING:
27-
from ._addressing import Address
2830
from ._typing import Protocol as _Protocol
2931
else:
3032
_Protocol = object
@@ -279,13 +281,13 @@ def from_raw_values(cls, values: _t.Iterable[str]) -> Bookmarks:
279281
class ServerInfo:
280282
"""Represents a package of information relating to a Neo4j server."""
281283

282-
def __init__(self, address: Address, protocol_version: tuple[int, int]):
284+
def __init__(self, address: _Address, protocol_version: tuple[int, int]):
283285
self._address = address
284286
self._protocol_version = protocol_version
285287
self._metadata: dict = {}
286288

287289
@property
288-
def address(self) -> Address:
290+
def address(self) -> _Address:
289291
"""Network address of the remote server."""
290292
return self._address
291293

@@ -314,7 +316,7 @@ def update(self, metadata: dict) -> None:
314316
self._metadata.update(metadata)
315317

316318

317-
class BookmarkManager(_Protocol, metaclass=abc.ABCMeta):
319+
class BookmarkManager(_Protocol, metaclass=_abc.ABCMeta):
318320
"""
319321
Class to manage bookmarks throughout the driver's lifetime.
320322
@@ -355,7 +357,7 @@ class BookmarkManager(_Protocol, metaclass=abc.ABCMeta):
355357
.. versionchanged:: 5.8 Stabilized from experimental.
356358
"""
357359

358-
@abc.abstractmethod
360+
@_abc.abstractmethod
359361
def update_bookmarks(
360362
self,
361363
previous_bookmarks: _t.Collection[str],
@@ -371,7 +373,7 @@ def update_bookmarks(
371373
"""
372374
...
373375

374-
@abc.abstractmethod
376+
@_abc.abstractmethod
375377
def get_bookmarks(self) -> _t.Collection[str]:
376378
"""
377379
Return the bookmarks stored in the bookmark manager.
@@ -381,7 +383,7 @@ def get_bookmarks(self) -> _t.Collection[str]:
381383
...
382384

383385

384-
class AsyncBookmarkManager(_Protocol, metaclass=abc.ABCMeta):
386+
class AsyncBookmarkManager(_Protocol, metaclass=_abc.ABCMeta):
385387
"""
386388
Same as :class:`.BookmarkManager` but with async methods.
387389
@@ -396,7 +398,7 @@ class AsyncBookmarkManager(_Protocol, metaclass=abc.ABCMeta):
396398
.. versionchanged:: 5.8 Stabilized from experimental.
397399
"""
398400

399-
@abc.abstractmethod
401+
@_abc.abstractmethod
400402
async def update_bookmarks(
401403
self,
402404
previous_bookmarks: _t.Collection[str],
@@ -405,7 +407,7 @@ async def update_bookmarks(
405407

406408
update_bookmarks.__doc__ = BookmarkManager.update_bookmarks.__doc__
407409

408-
@abc.abstractmethod
410+
@_abc.abstractmethod
409411
async def get_bookmarks(self) -> _t.Collection[str]: ...
410412

411413
get_bookmarks.__doc__ = BookmarkManager.get_bookmarks.__doc__

src/neo4j/exceptions.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
+ ConnectionAcquisitionTimeoutError
6161
"""
6262

63-
from __future__ import annotations
63+
from __future__ import annotations as _
6464

6565
from copy import deepcopy as _deepcopy
6666
from enum import Enum as _Enum
@@ -71,26 +71,26 @@
7171

7272
if _t.TYPE_CHECKING:
7373
from ._async.work import (
74-
AsyncManagedTransaction,
75-
AsyncResult,
76-
AsyncSession,
77-
AsyncTransaction,
74+
AsyncManagedTransaction as _AsyncManagedTransaction,
75+
AsyncResult as _AsyncResult,
76+
AsyncSession as _AsyncSession,
77+
AsyncTransaction as _AsyncTransaction,
7878
)
7979
from ._sync.work import (
80-
ManagedTransaction,
81-
Result,
82-
Session,
83-
Transaction,
80+
ManagedTransaction as _ManagedTransaction,
81+
Result as _Result,
82+
Session as _Session,
83+
Transaction as _Transaction,
8484
)
8585

8686
_TTransaction: _t.TypeAlias = (
87-
AsyncManagedTransaction
88-
| AsyncTransaction
89-
| ManagedTransaction
90-
| Transaction
87+
_AsyncManagedTransaction
88+
| _AsyncTransaction
89+
| _ManagedTransaction
90+
| _Transaction
9191
)
92-
_TResult: _t.TypeAlias = AsyncResult | Result
93-
_TSession: _t.TypeAlias = AsyncSession | Session
92+
_TResult: _t.TypeAlias = _AsyncResult | _Result
93+
_TSession: _t.TypeAlias = _AsyncSession | _Session
9494
_T = _t.TypeVar("_T")
9595

9696

src/neo4j/graph/__init__.py

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

1717
"""Graph data types as returned by the DBMS."""
1818

19-
from __future__ import annotations
19+
from __future__ import annotations as _
2020

21-
from collections.abc import Mapping
21+
from collections.abc import Mapping as _Mapping
2222

2323
from .. import _typing as _t
2424

2525

2626
if _t.TYPE_CHECKING:
27-
from typing_extensions import deprecated
27+
from typing_extensions import deprecated as _deprecated
2828
else:
29-
from .._warnings import deprecated
29+
from .._warnings import deprecated as _deprecated
3030

3131

3232
__all__ = [
@@ -151,7 +151,7 @@ def graph(self) -> Graph:
151151
return self._graph
152152

153153
@property # type: ignore
154-
@deprecated("`id` is deprecated, use `element_id` instead")
154+
@_deprecated("`id` is deprecated, use `element_id` instead")
155155
def id(self) -> int:
156156
"""
157157
The legacy identity of this entity in its container :class:`.Graph`.
@@ -200,7 +200,7 @@ def items(self) -> _t.ItemsView[str, _t.Any]:
200200
return self._properties.items()
201201

202202

203-
class EntitySetView(Mapping, _t.Generic[_T]):
203+
class EntitySetView(_Mapping, _t.Generic[_T]):
204204
"""View of a set of :class:`.Entity` instances within a :class:`.Graph`."""
205205

206206
def __init__(

0 commit comments

Comments
 (0)