+
Skip to content

Conversation

bsowell
Copy link
Contributor

@bsowell bsowell commented May 29, 2025

This method is used in some of the Jinja prompt formatters via Element::field_to_value. It previously assumed the object it was traversing was a dict and used the get method to look up values. In elements, this bypassed the @Property getters, which could lead to incorrect values. I observed the text_representation of a TableElement being null, because the value is set to the csv representation of the table in the getter.

This method is used in some of the Jinja prompt formatters via
Element::field_to_value. It previously assumed the object it was traversing
was a dict and used the get method to look up values. In elements, this
bypassed the @Property getters, which could lead to incorrect values. I
observed the text_representation of a TableElement being null, because the
value is set to the csv representation of the table in the getter.
@bsowell bsowell requested review from HenryL27 and Copilot May 29, 2025 20:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses an issue with the nested_lookup utility by enabling proper attribute resolution via property getters.

  • In lib/sycamore/sycamore/utils/nested.py, the lookup logic is updated to use getattr for objects that have properties.
  • In lib/sycamore/sycamore/tests/unit/data/test_element.py, tests are added to validate the behavior for TableElement and its property-based text representation.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/sycamore/sycamore/utils/nested.py Updated nested_lookup to use attribute access for properties.
lib/sycamore/sycamore/tests/unit/data/test_element.py Added unit tests for TableElement to validate field-to-value mapping.

@bsowell bsowell merged commit 023fe22 into main May 29, 2025
12 of 15 checks passed
@bsowell bsowell deleted the ben/fix_nested branch May 29, 2025 22:08
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.

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载