Skip to content

Remove deprecated exports from neo4j #1160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 1 addition & 38 deletions src/neo4j/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


import typing as _t
from logging import getLogger as _getLogger

from ._api import ( # noqa: F401 dynamic attributes
NotificationCategory,
Expand All @@ -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 (
Expand All @@ -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,
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -139,7 +131,6 @@
"BoltDriver",
"Bookmark",
"Bookmarks",
"Config", # noqa: F822 dynamic attribute
"Driver",
"EagerResult",
"ExperimentalWarning",
Expand All @@ -155,7 +146,6 @@
"NotificationDisabledClassification",
"NotificationMinimumSeverity",
"NotificationSeverity",
"PoolConfig", # noqa: F822 dynamic attribute
"PreviewWarning",
"Query",
"Record",
Expand All @@ -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",
Expand Down
29 changes: 1 addition & 28 deletions tests/unit/common/test_import_neo4j.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def test_import_neo4j():
("BoltDriver", None),
("Bookmark", None),
("Bookmarks", None),
("Config", DeprecationWarning),
("custom_auth", None),
("DEFAULT_DATABASE", None),
("Driver", None),
Expand All @@ -57,7 +56,6 @@ def test_import_neo4j():
("IPv4Address", None),
("IPv6Address", None),
("kerberos_auth", None),
("log", DeprecationWarning),
("ManagedTransaction", None),
("Neo4jDriver", None),
("NotificationCategory", None),
Expand All @@ -66,7 +64,6 @@ def test_import_neo4j():
("NotificationDisabledClassification", PreviewWarning),
("NotificationMinimumSeverity", None),
("NotificationSeverity", None),
("PoolConfig", DeprecationWarning),
("PreviewWarning", None),
("Query", None),
("READ_ACCESS", None),
Expand All @@ -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),
Expand All @@ -90,7 +85,6 @@ def test_import_neo4j():
("TrustSystemCAs", None),
("unit_of_work", None),
("Version", None),
("WorkspaceConfig", DeprecationWarning),
("WRITE_ACCESS", None),
)

Expand Down Expand Up @@ -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",
Expand Down