-
Notifications
You must be signed in to change notification settings - Fork 10
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
Prepend builtins base name #209
Conversation
d913be5
to
a352c72
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #209 +/- ##
==========================================
- Coverage 96.26% 96.25% -0.01%
==========================================
Files 88 89 +1
Lines 4065 4089 +24
==========================================
+ Hits 3913 3936 +23
- Misses 152 153 +1
|
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.
@andrecsilva can you explain the motivation for this change? Given the caveat that you mentioned, I am not entirely convinced that this is the behavior we want.
The goal is to be closer to the |
Given the caveat, my personal preference would be to not accept this change. |
I'm happy to say that I was mistaken and it is actually working as intended. You can check for yourself with the following small example: import libcst as cst
from libcst.codemod import Codemod, CodemodContext
from codemodder.codemods.utils_mixin import NameResolutionMixin
class A(Codemod, NameResolutionMixin):
def transform_module_impl(self, tree):
node = tree.body[0].body[0].value
print(node)
print(self.is_builtin_function(node))
print(self.find_base_name(node))
return tree
tree = cst.parse_module("foo()")
A(CodemodContext()).transform_module(tree) |
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
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.
nice! 👏
Overview
find_base_name will now prepend builtins for builtin names.
A caveat of this change is thatlibcst
considers any name that is not imported or originates in the module as builtin. This means that in:foo()
foo
is considered builtin.Disregard this caveat, it's actually working correctly. I assume that it was behaving like this because of a test case I had to change.