Skip to content

Bugfix: Restore support for custom input, alongside text and TextSlice#1562

Merged
erezsh merged 2 commits intomasterfrom
issue1560
Oct 22, 2025
Merged

Bugfix: Restore support for custom input, alongside text and TextSlice#1562
erezsh merged 2 commits intomasterfrom
issue1560

Conversation

@erezsh
Copy link
Copy Markdown
Member

@erezsh erezsh commented Oct 21, 2025

Fixes issue #1560

@lark-parser lark-parser deleted a comment from codecov Bot Oct 21, 2025
Copy link
Copy Markdown
Member

@MegaIng MegaIng left a comment

Choose a reason for hiding this comment

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

Excluding those two minor style changes, this looks good.

Sorry, I also forgot about this usecase when reviewing the original change set.

Comment thread lark/parser_frontends.py Outdated
Comment thread lark/utils.py


TextOrSlice = Union[AnyStr, 'TextSlice[AnyStr]']
LarkInput = Union[AnyStr, TextSlice[AnyStr], Any]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would write this as LarkInput = Union[TextOrSlice, Any] to make it clearer what the logic here is. Functionally they are equivalent.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I guess Any overrides any other type in the union, but I want there to be an explicit list of the types that could be accepted in the normal case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO the explicit lists is also just above the line anyway, but sure, if you want to keep it like this that's fine.

(And yes, from a type-checking perspective having Any in there removes all checks - to fix this we would need essentially depended types which don't (yet) exists in python's typing system)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have a mild preference to keeping it this way.

If we really cared about typing, we could have a different function like parse_custom(). But I'm not sure if it's worth the trouble.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not IMO and still a breaking change.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.97%. Comparing base (e332c2d) to head (7c365de).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
lark/lexer.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1562      +/-   ##
==========================================
+ Coverage   89.93%   89.97%   +0.03%     
==========================================
  Files          52       52              
  Lines        7987     8018      +31     
==========================================
+ Hits         7183     7214      +31     
  Misses        804      804              
Flag Coverage Δ
unittests 89.97% <97.91%> (+0.03%) ⬆️

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.

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

@erezsh erezsh merged commit 1f6f03c into master Oct 22, 2025
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.

2 participants