Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 18, 2026

Enables documenting schema columns using docstrings placed immediately after column definitions, allowing structured documentation that can be programmatically accessed and preserved through serialization.

Changes

Docstring extraction

  • Added AST parser in _base_schema.py to extract docstrings following column assignments
  • Integrated extraction into SchemaMeta.__new__() to capture docstrings at class creation

Column class updates

  • Added doc attribute to Column.__init__()
  • Modified serialization to preserve doc in as_dict()/from_dict()
  • Updated matches() to compare doc values
  • Extended __repr__() to display non-null doc values

Testing

  • Added 11 tests covering extraction, serialization, inheritance, multiline strings, and edge cases

Usage

class HouseSchema(dy.Schema):
    """Schema for real estate data"""
    
    zip_code = dy.String(nullable=False, min_length=3)
    """Postal code where the property is located"""
    
    num_bedrooms = dy.UInt8(nullable=False)
    """Number of bedrooms, excluding living areas"""

# Access programmatically
HouseSchema.columns()["zip_code"].doc  # "Postal code where..."

# Preserved in serialization
serialized = HouseSchema.serialize()
deserialized = deserialize_schema(serialized)
assert deserialized.columns()["zip_code"].doc == "Postal code where..."

# Visible in repr
print(HouseSchema)  
# [Schema "HouseSchema"]
#   Columns:
#     - "zip_code": String(min_length=3, doc='Postal code where...')

Limitations

Docstrings are extracted via inspect.getsource(), so dynamically created schemas (via exec()) won't have docstrings available. This matches standard Python docstring behavior.

Original prompt

This section details on the original issue you should resolve

<issue_title>Support for docstring styled column documentation</issue_title>
<issue_description>Feature request to allow for columns level docstrings in the following form:

class HouseSchema(dy.Schema):
    """Explanation of what my House Schema is really representing"""
    
    zip_code = dy.String(nullable=False, min_length=3)
    """A zip_code is a ..."""
    
    num_bedrooms = dy.UInt8(nullable=False)
    """Counts the rooms in a house not including the living room, kitchen and ..."""

    etc

This could potentially allow for printing of schema documentation notes into a standardised/centralised format (e.g., to support with creating data documentation)</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 18, 2026 13:33
Co-authored-by: borchero <22455425+borchero@users.noreply.github.com>
Co-authored-by: borchero <22455425+borchero@users.noreply.github.com>
Co-authored-by: borchero <22455425+borchero@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for docstring styled column documentation feat: Support docstring-styled column documentation Jan 18, 2026
@github-actions github-actions bot added the enhancement New feature or request label Jan 18, 2026
Copilot AI requested a review from borchero January 18, 2026 13:44
@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.96%. Comparing base (78bb16d) to head (cda1f70).

Files with missing lines Patch % Lines
dataframely/_base_schema.py 96.96% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main     #261      +/-   ##
===========================================
- Coverage   100.00%   99.96%   -0.04%     
===========================================
  Files           53       53              
  Lines         3098     3141      +43     
===========================================
+ Hits          3098     3140      +42     
- Misses           0        1       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for docstring styled column documentation

2 participants