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: fail on unmatched tags #34

Merged
merged 2 commits into from
Dec 24, 2024

Conversation

shklqm
Copy link

@shklqm shklqm commented Dec 16, 2024

While playing with this library I noticed that for the tags that were not closed or not properly matched the parsing didn't fail.
I have added a few test cases to demonstrate this behavior.

PS: I used mustache playground to run & compare the results:
https://jgonggrijp.gitlab.io/wontache/playground.html

In the case there are unmatched tags, after the search
is done, the parsing should fail.
@bakert
Copy link
Member

bakert commented Dec 19, 2024

This is quite a change in behavior. I agree that it's desirable but it will need a major version bump as any old stuff might start exploding where as it would have been doing whatever arbitrary thing uncomplainingly until now. v1.0.0?

@shklqm
Copy link
Author

shklqm commented Dec 19, 2024

That's a good point. How about making it optional first, something like:

def parse(self, template, raise_on_mismatch=False):
      ...
      if raise_on_mismatch and states:
          raise ParsingError('Tag mismatch.')

In this way the compatibility is kept, and the argument can be deprecated at some later point.

@bakert
Copy link
Member

bakert commented Dec 20, 2024

That's a good point. How about making it optional first, something like:

def parse(self, template, raise_on_mismatch=False):
      ...
      if raise_on_mismatch and states:
          raise ParsingError('Tag mismatch.')

In this way the compatibility is kept, and the argument can be deprecated at some later point.

That's pretty weak compared to the more desirable behavior of letting you know that you fucked up but it might be a more responsible change.

In the normal behaviour, if there's a tag mismatch the
parse function, will run succesfully. In case the this marked
as True, then the parse will raise an exception.

This is intended for stricter parsing.
@bakert bakert merged commit ff177c4 into PennyDreadfulMTG:master Dec 24, 2024
28 checks passed
@bakert
Copy link
Member

bakert commented Dec 24, 2024

v0.6.7 now the latest on pypi has this

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