-
Notifications
You must be signed in to change notification settings - Fork 20
Conversation
Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Alexander Bezzubov <bzz@apache.org>
Signed-off-by: Alexander Bezzubov <bzz@apache.org>
Signed-off-by: Alexander Bezzubov <bzz@apache.org>
Signed-off-by: Alexander Bezzubov <bzz@apache.org>
Signed-off-by: Alexander Bezzubov <bzz@apache.org>
Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Install script should be fixed. |
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Was trying to test
but then
@juanjo I belive it has to do with 24fd7b6 as When I manually roll it back to aliases.py it seems to work. |
Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
@dennwc PTAL at the last commit. Should work on Linux (works on my machine and my Docker image) but as we talked on Slack it'll require the libuast package to include static libraries and it's untested on Windows and Darwin. It also have |
Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Denys Smirnov <denys@sourced.tech>
@bzz everything in your review should be solved. |
@vmarkovtsev would you be so kind to please review the API changes? Thanks! |
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.
My minor comments and questions. Main part looks good 👍 .
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
# are alterative typed versions: | ||
x = next(ctx.filter("boolean(//*[@strtOffset or @endOffset])").get_bool() | ||
y = next(ctx.filter("name(//*[1])")).get_str() | ||
z = next(ctx.filter("count(//*)").get_int() # or get_float() |
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 is not very Pythonic. IDK if it is hard to guess the type, but the following is more Pythonic:
x = next(ctx.filter("boolean(//*[@strtOffset or @endOffset])").iterate())
for name in ctx.filter("name(//*[1])").iterate():
print(name)
Where iterate()
would be an unordered iterator over the resulting values. Or name it results()
. Or remove it and iterate directly, anyway.
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.
Those are typed functions for queries returning boolean/string/integer/float values instead of nodes so the "typed get" is needed when the user doesn't have to do isinstance
of the results to check that they're right every time (but if he wants, he can use the normal get()
).
for i in newiter: ... | ||
|
||
# You can also get the non semantic UAST or native AST: | ||
ctx = client.parse("file.py", mode=bblfsh.ModeDict["NATIVE"]) |
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.
We should use an enum class or define separate constants instead of raw strings.
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.
It's mapping the protocol_v2_module.Mode.DESCRIPTOR.values_by_name
field. Maybe we could generate variable names from these strings using eval
or exec
but that's almost worse.
So given that we no longer have a |
Daaaamn, we have to rewrite bloody months of work in the style-analyzer's feature extraction without this emulation. Very painful. |
@vmarkovtsev That was my point of view, when I disliked the breaking changes. It doesn't make sense for you to write a |
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
…y Vadim Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Re "typed get" issue mentioned above, I agree with @vmarkovtsev - I don't see the reason for typed get helpers. Python is a dynamic language, so it should be okay to iterate over nodes directly (that already are strings/ints/whatever). Old client had those helpers because the way |
Python is dynamically typed but not weakly typed so it's not considered good practice on Python to have variant return types from the same function other than None. Also, having typed functions make easier to use mypy and avoid doing "if isinstance(...)" on every value, which would also be slower (or risking having buggy code using types without checking them). Plus is basically free to have them on the API. |
@juanjux OK, thanks for clarifying it. I trust your decision here. |
Update: I started to work on a compatiblity layer with v2 before the holidays, but it's stopped to work on the very prioritary C# driver, I'll continue with it ASAP once the driver is finished so we can finally publish this version. |
Since this passed review from the team, I propose to merge it (WITHOUT releasing v3 yet) so the compatiblity layer PR will be much easier to review as a separate one. Both PRs, once merged, would then be released as V3. What do you think? |
That sounds reasonable to me. |
Sounds good. Let's merge it. |
Work-in-progress implementation of Python client v3 for the new libuast.
TODO:
README.md
testFilterToken
once the SDK problem has been fixed.Node
compatibility layer.Signed-off-by: Denys Smirnov denys@sourced.tech