-
Notifications
You must be signed in to change notification settings - Fork 16
Address feedback from PR #241 #244
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
Address feedback from PR #241 #244
Conversation
tekknolagi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm pending fixes
scrapscript.py
Outdated
| result.source_extent.end.byteno = self.current_token_source_extent.end.byteno | ||
|
|
||
| return result | ||
| return make_source_annotated_token(cls, copy.deepcopy(self.current_token_source_extent), *args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you use dataclasses, you get a copy for free. Try calling .replace() (no arguments)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion; actually, it seems that replace is a free-standing function defined in module dataclasses, so I had to do replace(self.current_token_source_extent). However, this failed the tests since it did not seem to do a deep copy of the dataclass fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, riparoni
scrapscript_tests.py
Outdated
| int_ast = make_source_annotated_object(Int, source_extent, 1) | ||
| self.assertTrue(parse(Peekable(iter([int_lit]))).source_extent == int_ast.source_extent) | ||
| int_lit = make_source_annotated_token(IntLit, source_extent, 1) | ||
| self.assertTrue(parse(Peekable(iter([int_lit]))).source_extent == source_extent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertEqual, please (here and everywhere)
|
You may also find it useful to convert |
tekknolagi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweet, thanks
I added a function called
make_source_annotated_tokento simplify the repeated logic in the source extent tests, but if it's unnecessary I can easily revert those commits.Edit: Linking the PR for easy, future reference: #241.