-
Notifications
You must be signed in to change notification settings - Fork 602
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
Using DotAccess instead of IdQualified for Python decorators #10221
Conversation
PR checklist:
If you're unsure about any of this, please see: |
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.
some tests/patterns/python/xxx.sgrep test file would be nice.
Otherwise LGTM.
semgrep-compare-github-brzbo resultsRan benchmark on 38 repositories The number of files checked differs for 1 repos The number of findings differs for 2 repos Whole benchmark is 0.1% slower (a bit of noise is expected) Relative speed improvement is 1.01 on average
Relative memory improvement is 1.00 on average |
@@ -0,0 +1,3 @@ | |||
@$X.route(...) |
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.
Didn't this test already work before?
|> G.e) | ||
base | ||
in | ||
G.OtherAttribute |
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.
TBH I would have added ExprAttr
.
test plan:
make test
This PR modifies the translation of Python decorators. In Python, it's generally impossible to distinguish whether a given fully qualified name points to a specific program entity or if it's a field access based on the object instance. Previously, we used
IdQualified
for all Python decorators with multiple components separated by dots. However, this approach encountered an issue when attempting to use ametavariable-type
filter on the middle component of the Python decorator. This is becauseIdQualified
doesn't haveid_info
for itsQDot
middle component, meaning that the middle component ofIdQualified
cannot be resolved by the naming phase.To address this problem, we now translate Python decorators into
DotAccess
instead ofIdQualified
. Each field name inDotAccess
can be anId
, which hasid_info
, allowing us to resolve its type information in the naming phase.