From cc1eefe69b9de3a00f863611290d59478be1d43d Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Thu, 24 Apr 2025 15:39:30 +0200 Subject: [PATCH] Remove deprecated exports from `neo4j` --- CHANGELOG.md | 4 ++- src/neo4j/__init__.py | 39 +------------------------- tests/unit/common/test_import_neo4j.py | 29 +------------------ 3 files changed, 5 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e15d2d1a..36f6250f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,9 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog. ## NEXT RELEASE -- No breaking or major changes. +- Remove deprecated exports from `neo4j`: + - `log`, `Config`, `PoolConfig`, `SessionConfig`, `WorkspaceConfig` (internal - no replacement) + - `SummaryNotificationPosition` (use `SummaryInputPosition` instead) ## Version 5.28 diff --git a/src/neo4j/__init__.py b/src/neo4j/__init__.py index f881e3c3..d8557665 100644 --- a/src/neo4j/__init__.py +++ b/src/neo4j/__init__.py @@ -15,7 +15,6 @@ import typing as _t -from logging import getLogger as _getLogger from ._api import ( # noqa: F401 dynamic attributes NotificationCategory, @@ -37,13 +36,10 @@ AsyncSession, AsyncTransaction, ) -from ._conf import ( # noqa: F401 dynamic attribute - Config as _Config, - SessionConfig as _SessionConfig, +from ._conf import ( TrustAll, TrustCustomCAs, TrustSystemCAs, - WorkspaceConfig as _WorkspaceConfig, ) from ._data import Record from ._meta import ( @@ -55,9 +51,6 @@ PreviewWarning, version as __version__, ) -from ._sync.config import ( # noqa: F401 dynamic attribute - PoolConfig as _PoolConfig, -) from ._sync.driver import ( BoltDriver, Driver, @@ -88,7 +81,6 @@ from ._work import ( GqlStatusObject, # noqa: TCH004 false positive (dynamic attribute) NotificationClassification, # noqa: TCH004 false positive (dynamic attribute) - SummaryInputPosition as SummaryNotificationPosition, # noqa: TCH004 false positive (dynamic attribute) ) from .addressing import ( @@ -139,7 +131,6 @@ "BoltDriver", "Bookmark", "Bookmarks", - "Config", # noqa: F822 dynamic attribute "Driver", "EagerResult", "ExperimentalWarning", @@ -155,7 +146,6 @@ "NotificationDisabledClassification", "NotificationMinimumSeverity", "NotificationSeverity", - "PoolConfig", # noqa: F822 dynamic attribute "PreviewWarning", "Query", "Record", @@ -164,53 +154,26 @@ "RoutingControl", "ServerInfo", "Session", - "SessionConfig", # noqa: F822 dynamic attribute "SummaryCounters", "SummaryInputPosition", "SummaryNotification", - "SummaryNotificationPosition", "Transaction", "TrustAll", "TrustCustomCAs", "TrustSystemCAs", "Version", - "WorkspaceConfig", # noqa: F822 dynamic attribute "__version__", "basic_auth", "bearer_auth", "custom_auth", "get_user_agent", "kerberos_auth", - "log", # noqa: F822 dynamic attribute "unit_of_work", ] -_log = _getLogger("neo4j") - - def __getattr__(name) -> _t.Any: # TODO: 6.0 - remove this - if name in { - "log", - "Config", - "PoolConfig", - "SessionConfig", - "WorkspaceConfig", - }: - _deprecation_warn( - f"Importing {name} from neo4j is deprecated without replacement. " - "It's internal and will be removed in a future version.", - stack_level=2, - ) - return globals()[f"_{name}"] - if name == "SummaryNotificationPosition": - _deprecation_warn( - "SummaryNotificationPosition is deprecated. " - "Use SummaryInputPosition instead.", - stack_level=2, - ) - return SummaryInputPosition if name in { "NotificationClassification", "GqlStatusObject", diff --git a/tests/unit/common/test_import_neo4j.py b/tests/unit/common/test_import_neo4j.py index 7f7033c9..1e6dbf00 100644 --- a/tests/unit/common/test_import_neo4j.py +++ b/tests/unit/common/test_import_neo4j.py @@ -45,7 +45,6 @@ def test_import_neo4j(): ("BoltDriver", None), ("Bookmark", None), ("Bookmarks", None), - ("Config", DeprecationWarning), ("custom_auth", None), ("DEFAULT_DATABASE", None), ("Driver", None), @@ -57,7 +56,6 @@ def test_import_neo4j(): ("IPv4Address", None), ("IPv6Address", None), ("kerberos_auth", None), - ("log", DeprecationWarning), ("ManagedTransaction", None), ("Neo4jDriver", None), ("NotificationCategory", None), @@ -66,7 +64,6 @@ def test_import_neo4j(): ("NotificationDisabledClassification", PreviewWarning), ("NotificationMinimumSeverity", None), ("NotificationSeverity", None), - ("PoolConfig", DeprecationWarning), ("PreviewWarning", None), ("Query", None), ("READ_ACCESS", None), @@ -76,11 +73,9 @@ def test_import_neo4j(): ("RoutingControl", None), ("ServerInfo", None), ("Session", None), - ("SessionConfig", DeprecationWarning), ("SummaryCounters", None), ("SummaryInputPosition", None), ("SummaryNotification", None), - ("SummaryNotificationPosition", DeprecationWarning), ("SYSTEM_DATABASE", None), ("Transaction", None), ("TRUST_ALL_CERTIFICATES", None), @@ -90,7 +85,6 @@ def test_import_neo4j(): ("TrustSystemCAs", None), ("unit_of_work", None), ("Version", None), - ("WorkspaceConfig", DeprecationWarning), ("WRITE_ACCESS", None), ) @@ -129,28 +123,7 @@ def test_dir(): def test_import_star(): with pytest.warns() as warnings: importlib.__import__("neo4j", fromlist=("*",)) - assert len(warnings) == 9 - assert all( - issubclass(w.category, (DeprecationWarning, PreviewWarning)) - for w in warnings - ) - - for name in ( - "log", - "Config", - "PoolConfig", - "SessionConfig", - "WorkspaceConfig", - "SummaryNotificationPosition", - ): - assert ( - sum( - bool(re.match(rf".*\b{name}\b.*", str(w.message))) - for w in warnings - if issubclass(w.category, DeprecationWarning) - ) - == 1 - ) + assert len(warnings) == 3 for name in ( "NotificationClassification",