-
Notifications
You must be signed in to change notification settings - Fork 120
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 the pattern AST creation function #344
Conversation
documentation at least isn't wrong, and it behaves better.
Codecov Report
@@ Coverage Diff @@
## master #344 +/- ##
==========================================
+ Coverage 98.1% 98.16% +0.05%
==========================================
Files 124 124
Lines 14185 14158 -27
==========================================
- Hits 13916 13898 -18
+ Misses 269 260 -9
Continue to review full report at Codecov.
|
Looks great! I think we should have a test case to make sure the right exception class is being thrown. I wouldn't be opposed to also adding a visit() method. |
create_pattern_object().
advantage of the pattern validator library's Pattern.visit() method.
I added the visit() method and changed |
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!
Fixes #326
It seems like stix2.pattern_visitor.create_pattern_object() was written based on a copy-paste of a function from the pattern validator. But it wasn't changed enough. I fixed it up:
pattern[:2]
junk was from the validator checking whether the pattern starts with brackets. It doesn't belong in the AST builder. I removed it.If we want to make visitor use more convenient, maybe we should give the Pattern class(es) from the pattern validator a
visit()
method analogous to the walk() method?An example of error output now (with Python 3):