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

Use Lark with its cache feature, instead of creating a standalone parser #53

Merged
merged 6 commits into from
Jan 13, 2023

Conversation

erezsh
Copy link
Contributor

@erezsh erezsh commented Jan 12, 2021

The behavior and performance are the same, but the code is much shorter.

Copy link
Member

@aoskotsky-amplify aoskotsky-amplify left a comment

Choose a reason for hiding this comment

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

Hey, thanks a lot for this PR! This cleans it up a lot.

I noticed tox was failing so committed some lint fixes. I left a couple of questions in the comments. Let me know what you think and we can merge this.

test/unit/test_load.py Outdated Show resolved Hide resolved
@@ -15,4 +15,4 @@ def loads(text: str) -> dict:
# Lark doesn't support a EOF token so our grammar can't look for "new line or end of file"
# This means that all blocks must end in a new line even if the file ends
# Append a new line as a temporary fix
return hcl2.parse(text + "\n")
return hcl2.parse(text + "\n") # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

mypy was complaining that parse returns a Tree instead of a Dict. We can leave the ignore here but was curious why it does that.

@nyurik
Copy link

nyurik commented May 5, 2021

From dev-ops perspective, it would be great if python-hcl2 lib had no external dependencies. Lark is a fairly complex project to do a full security check on, thus reducing the usefulness of this amazing library. My (limited) understanding is that Lark can generate a custom python file for the specific grammar, making the Lark itself not required. Would it be possible to do that? Thanks!

See also #64

@htorianik htorianik requested a review from a team January 12, 2023 20:15
@rddimon rddimon dismissed aoskotsky-amplify’s stale review January 13, 2023 11:58

We added a comment with the explanation

@htorianik htorianik merged commit ac6d89f into amplify-education:master Jan 13, 2023
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.

6 participants