Skip to content

Commit 940d3c2

Browse files
fix: Allow heading introspection on base tier classes
The heading property now returns None for base tier classes (Lookup, Manual, Imported, Computed, Part) instead of raising an error. This allows Python's help() and inspect modules to work correctly. User-defined table classes still get the helpful error message when trying to access heading on a non-activated schema. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 67fcf43 commit 940d3c2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/datajoint/table.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,23 @@ def table_name(self):
120120
def class_name(self):
121121
return self.__class__.__name__
122122

123+
# Base tier class names that should not raise errors when heading is None
124+
_base_tier_classes = frozenset({"Table", "UserTable", "Lookup", "Manual", "Imported", "Computed", "Part"})
125+
123126
@property
124127
def heading(self):
125128
"""
126129
Return the table's heading, or raise a helpful error if not configured.
127130
128131
Overrides QueryExpression.heading to provide a clear error message
129132
when the table is not properly associated with an activated schema.
133+
For base tier classes (Lookup, Manual, etc.), returns None to support
134+
introspection (e.g., help()).
130135
"""
131136
if self._heading is None:
137+
# Don't raise error for base tier classes - they're used for introspection
138+
if self.__class__.__name__ in self._base_tier_classes:
139+
return None
132140
raise DataJointError(
133141
f"Table `{self.__class__.__name__}` is not properly configured. "
134142
"Ensure the schema is activated before using the table. "

0 commit comments

Comments
 (0)