Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for when providing a transformer with a Token #1395

Merged
merged 1 commit into from
Feb 26, 2024
Merged

Fix for when providing a transformer with a Token #1395

merged 1 commit into from
Feb 26, 2024

Conversation

erezsh
Copy link
Member

@erezsh erezsh commented Feb 25, 2024

Fixes issue #1394

@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.41%. Comparing base (7646fb3) to head (5448931).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1395      +/-   ##
==========================================
+ Coverage   89.39%   89.41%   +0.01%     
==========================================
  Files          52       52              
  Lines        7730     7744      +14     
==========================================
+ Hits         6910     6924      +14     
  Misses        820      820              
Flag Coverage Δ
unittests 89.41% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@@ -158,7 +158,11 @@ def _transform_tree(self, tree):

def transform(self, tree: Tree[_Leaf_T]) -> _Return_T:
"Transform the given tree, and return the final result"
return self._transform_tree(tree)
res = list(self._transform_children([tree]))
Copy link
Member

Choose a reason for hiding this comment

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

this has the side effect of also allowing everything that isn't a tree or token to be passed without error. Not sure if that is good behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

What's bad about it?

Copy link
Member

Choose a reason for hiding this comment

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

It might hide user error where they pass things that aren't the result of a Lark.parse call, which is probably never intentional. But this isn't a strong objection, if you think this is fine, go ahead.

Copy link
Member Author

@erezsh erezsh Feb 25, 2024

Choose a reason for hiding this comment

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

I see your point, but I think I'll keep it. My reasoning is that:

  1. We allow Lark.parse to return an arbitrary object (through another transformer)

  2. It would make the root behave the same as the leaf, in which we allow arbitrary objects and just skip them without an error

  3. It's not the kind of mistake that is likely to proceed much without being noticed down the line. (though I admit in some edge cases it might happen)

@erezsh erezsh merged commit 7061908 into master Feb 26, 2024
23 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.

3 participants