-
Notifications
You must be signed in to change notification settings - Fork 33
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
Enhance rule success strategy #82
base: main
Are you sure you want to change the base?
Enhance rule success strategy #82
Conversation
I am not familiar enough with the project history to know if something similar was considered before. @pablogsal would know more but he has been quite busy recently. |
I don't think something like this was considered while initially working on the project. However, we were more focussed on the C generator, making such edge cases in the python generator easier to miss. To be honest, I'm a bit torn on this. While this seems like something that would work, I'm inclined to say that just checking Not a strong opinion, so I'll let @pablogsal make the final call. |
Almost, the original bug is that loop0 can return an empty list, wich is evaluates to be False, but it shoud be considered a successful match. This logic is fine for loop1, but not for loop0 So the smallest fix is to handle
If I think about it as a feature it does indeed looks to be a neat thing to have, but it's not necessarily lost. What I like about this implementation is that only the function itself (and not the caller) is responsible for saying is this a match or not On a side note I haven't had time to investigate what was the problem of a failed CI jobs, when I have the time I will look into that |
Ok so the problem is that memorization does not restore value of the
I don't want to touch the 2, although the logic keeping 1 seems to be a little messy it adds more code to the call (ex. 3 would grant the least amoung of changing but In the end I think that I tried to squish two prs/features into one, and if we really want to get read of the And I think that for now if users want to return Also if we want users be able to make empty values that are |
Ok, tox straight up just does not work, I ran all of the pytests, linting tests, regen-metaparser but tox refures to succeed either here or locally |
@@ -80,6 +80,9 @@ def __init__(self, name: str, type: Optional[str], rhs: Rhs, memo: Optional[obje | |||
def is_loop(self) -> bool: | |||
return self.name.startswith("_loop") | |||
|
|||
def is_loop1(self) -> bool: |
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.
this can be removes as it's not used anywhere
@@ -214,6 +217,16 @@ def visit_Name(self, node: ast.Name) -> Set[str]: | |||
return {node.id} | |||
|
|||
|
|||
class RuleProperties(NamedTuple): |
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.
this can be removes alongside is_loop1, as it then would not really add anything
although I still think it's nicer
5aae014
to
3cefc85
Compare
Closes #81
Also now it does not matter, if a user decides to return None as a node for some rule, now it will not affect anythingAlso now instead of calling bool on the returning objects (which may be expensive) only a boolean flag will be set
This will also help a little with #70
Use
func() is not None
where suitable and not rely on the boolean value of the returned object this seems to be more reasonable for more broader applicationsNow PythonCallMakerVisitor will determine if the value should be checked to be
not None
or should be checked as a boolean value (previous behavior)Also read the conversation