Skip to content

Commit 8e3d12f

Browse files
fix: remove deprecated dj.schema and dj.Di aliases
- Remove `schema` alias for `Schema` (use `dj.Schema` instead of `dj.schema`) - Remove `Di` alias for `Diagram` (use `dj.Diagram` or `dj.ERD`) - Update all examples, tests, and docstrings Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 3525aad commit 8e3d12f

File tree

7 files changed

+7
-13
lines changed

7 files changed

+7
-13
lines changed

src/datajoint/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"conn",
2525
"Connection",
2626
"Schema",
27-
"schema",
2827
"VirtualModule",
2928
"virtual_schema",
3029
"list_schemas",
@@ -40,7 +39,6 @@
4039
"Top",
4140
"U",
4241
"Diagram",
43-
"Di",
4442
"ERD",
4543
"kill",
4644
"MatCell",
@@ -89,8 +87,6 @@
8987
from .user_tables import Computed, Imported, Lookup, Manual, Part
9088
from .version import __version__
9189

92-
schema = Schema # Alias for Schema
93-
9490
# =============================================================================
9591
# Lazy imports — heavy dependencies loaded on first access
9692
# =============================================================================
@@ -100,7 +96,6 @@
10096
_lazy_modules = {
10197
# Diagram imports networkx and matplotlib
10298
"Diagram": (".diagram", "Diagram"),
103-
"Di": (".diagram", "Diagram"),
10499
"ERD": (".diagram", "Diagram"),
105100
"diagram": (".diagram", None), # Return the module itself
106101
# kill imports pymysql via connection

src/datajoint/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def __enter__(self) -> "Connection":
299299
Examples
300300
--------
301301
>>> with dj.Connection(host, user, password) as conn:
302-
... schema = dj.schema('my_schema', connection=conn)
302+
... schema = dj.Schema('my_schema', connection=conn)
303303
... # perform operations
304304
... # connection automatically closed
305305
"""

src/datajoint/migrate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def analyze_columns(schema: Schema) -> dict:
9090
--------
9191
>>> import datajoint as dj
9292
>>> from datajoint.migrate import analyze_columns
93-
>>> schema = dj.schema('my_database')
93+
>>> schema = dj.Schema('my_database')
9494
>>> result = analyze_columns(schema)
9595
>>> for col in result['needs_migration']:
9696
... print(f"{col['table']}.{col['column']}: {col['native_type']} → {col['core_type']}")
@@ -315,7 +315,7 @@ def analyze_blob_columns(schema: Schema) -> list[dict]:
315315
Examples
316316
--------
317317
>>> import datajoint as dj
318-
>>> schema = dj.schema('my_database')
318+
>>> schema = dj.Schema('my_database')
319319
>>> columns = dj.migrate.analyze_blob_columns(schema)
320320
>>> for col in columns:
321321
... if col['needs_migration']:

tests/integration/test_codecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def schema_codec(
3030
dj.config["stores"] = {"repo-s3": dict(s3_creds, protocol="s3", location="codecs/repo", stage=str(tmpdir))}
3131
# Codecs are auto-registered via __init_subclass__ in schema_codecs
3232
context = {**schema_codecs.LOCALS_CODECS}
33-
schema = dj.schema(schema_name, context=context, connection=connection_test)
33+
schema = dj.Schema(schema_name, context=context, connection=connection_test)
3434
schema(schema_codecs.Connectivity)
3535
schema(schema_codecs.Layout)
3636
yield schema

tests/integration/test_npy_codec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def schema_npy(connection_test, s3_creds, tmpdir, schema_name, mock_stores):
5656
"""Create schema with NpyCodec tables."""
5757
# mock_stores fixture sets up object_storage.stores with repo-s3, etc.
5858
context = dict(LOCALS_NPY)
59-
schema = dj.schema(schema_name, context=context, connection=connection_test)
59+
schema = dj.Schema(schema_name, context=context, connection=connection_test)
6060
schema(Recording)
6161
schema(MultiArray)
6262
yield schema

tests/integration/test_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_schema_list(schema_any):
6969
@pytest.mark.requires_mysql
7070
def test_drop_unauthorized(connection_test):
7171
"""Test that dropping information_schema raises AccessError."""
72-
info_schema = dj.schema("information_schema", connection=connection_test)
72+
info_schema = dj.Schema("information_schema", connection=connection_test)
7373
with pytest.raises(dj.errors.AccessError):
7474
info_schema.drop()
7575

tests/unit/test_lazy_imports.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ def test_diagram_aliases():
8989

9090
import datajoint as dj
9191

92-
# All aliases should resolve to the same class
93-
assert dj.Diagram is dj.Di
92+
# ERD alias should resolve to Diagram
9493
assert dj.Diagram is dj.ERD
9594

9695

0 commit comments

Comments
 (0)