Skip to content

Conversation

@dsillman2000
Copy link
Owner

@dsillman2000 dsillman2000 commented Feb 9, 2026

Overview

This MR drastically simplifies the yaml-reference implementation by consolidating functionality into the main __init__.py file and removing complex abstraction layers.

Key Changes

🗑️ Removed Files

  • yaml_reference/reference.py (305 lines) - Complex reference protocol and resolver system
  • yaml_reference/yaml.py (47 lines) - Custom YAMLReference class
  • yaml_reference/errors.py (4 lines) - ConstructorException class

New Implementation

  • Consolidated all functionality into yaml_reference/__init__.py
  • Added Reference and ReferenceAll classes with proper docstrings
  • Implemented parse_yaml_with_references() and load_yaml_with_references() functions
  • Updated CLI interface in yaml_reference/cli.py to use new methods

🔧 API Changes

  • Old: YAMLReference() class with complex inheritance
  • New: Simple functions load_yaml_with_references() and parse_yaml_with_references()
  • Example:
    # Before
    from yaml_reference import YAMLReference
    yaml = YAMLReference()
    data = yaml.load("root.yaml")
    
    # After
    from yaml_reference import load_yaml_with_references
    data = load_yaml_with_references("root.yaml")

📚 Documentation Updates

  • Updated README with new API examples
  • Added safety note about circular references
  • Clarified reference resolution behavior

🧪 Test Updates

  • Updated unit tests to work with new simplified API
  • Maintained test coverage for reference resolution

Benefits

  1. Simpler codebase - Reduced complexity and abstraction layers
  2. Clearer API - Function-based interface instead of class inheritance
  3. Easier maintenance - All logic in one file
  4. Better documentation - Clear docstrings and examples

Notes

  • Circular reference detection is not implemented (as per specification)
  • Uses ruamel.yaml's safe loader by default
  • Backward compatible for end users (different API but same functionality)

@dsillman2000 dsillman2000 merged commit 0c17a43 into main Feb 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant