Skip to content

Fix from neo4j import * statement #1009

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

Merged
merged 2 commits into from
Jan 9, 2024
Merged
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
2 changes: 0 additions & 2 deletions src/neo4j/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
"NotificationMinimumSeverity",
"Neo4jDriver",
"NotificationCategory",
"NotificationFilter",
"NotificationSeverity",
"PoolConfig",
"PreviewWarning",
Expand All @@ -145,7 +144,6 @@
"Record",
"Result",
"ResultSummary",
"RenewableAuth",
"RoutingControl",
"ServerInfo",
"Session",
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/common/test_import_neo4j.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# limitations under the License.


import importlib

import pytest


Expand Down Expand Up @@ -166,3 +168,19 @@ def test_import_time():

def test_import_exceptions():
from neo4j import exceptions


def test_import_star():
with pytest.warns() as warnings:
importlib.__import__("neo4j", fromlist=("*",))
assert len(warnings) == 5
assert all(issubclass(w.category, DeprecationWarning) for w in warnings)
messages = {str(w.message) for w in warnings}
for item in (
"log", "Config", "PoolConfig", "SessionConfig", "WorkspaceConfig"
):
message = (
f"Importing {item} from neo4j is deprecated without replacement. "
f"It's internal and will be removed in a future version."
)
assert message in messages