Skip to content

Commit b02d549

Browse files
vmarkovtsevzurk
andauthored
Apply suggestions from code review
Co-Authored-By: zurk <[email protected]>
1 parent b48822c commit b02d549

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lookout/core/analyzer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def to_pb(self) -> ApiReferencePointer:
3737
UnicodeFile.__doc__ = """
3838
UnicodeFile is an alternative to `lookout.core.api.service_data_pb2.File`.
3939
It is used in case `@with_unicode_data_service` decorator is applied.
40-
The main difference is that `content` field is a unicode string and uast offsets are changed to
40+
The main difference is that `content` field is a Unicode string and the node offsets are changed to
4141
corresponding unicode string offsets.
4242
""".strip()
4343

@@ -46,8 +46,8 @@ def to_pb(self) -> ApiReferencePointer:
4646
UnicodeChange.__doc__ = """
4747
UnicodeFile is an alternative to `lookout.core.api.service_data_pb2.Change`.
4848
It is used in case `@with_unicode_data_service` decorator is applied.
49-
The main difference is that `base` and `head` fields have type `UnicodeFile`. For more info read
50-
documentation about `UnicodeFile`.
49+
The main difference is that `base` and `head` fields have type `UnicodeFile`. For more info refer to
50+
the documentation about `UnicodeFile`.
5151
""".strip()
5252

5353

lookout/core/bytes_to_unicode_converter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def convert_uast(self, uast: bblfsh.Node) -> bblfsh.Node:
3434
:param uast: corresponding UAST.
3535
:return: UAST with unicode positions.
3636
"""
37-
uast = bblfsh.Node.FromString(uast.SerializeToString())
37+
uast = bblfsh.Node.FromString(uast.SerializeToString()) # deep copy the whole tree
3838
if not self._content:
3939
return uast
4040
for node in self._traverse_uast(uast):
@@ -89,7 +89,7 @@ def _build_bytes_to_str_offset_mapping(content: bytes) -> Dict[int, int]:
8989
return byte_to_str_offset
9090

9191
@staticmethod
92-
def _traverse_uast(uast: "bblfsh.Node"):
92+
def _traverse_uast(uast: "bblfsh.Node") -> Iterator["bblfsh.Node"]:
9393
stack = [uast]
9494
while stack:
9595
node = stack.pop(0)

lookout/core/data_requests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _get_channel(self) -> grpc.Channel:
9090

9191

9292
class UnicodeDataService(DataService):
93-
"""Retrieves UASTs/files from the Lookout server and converts in to unicode data."""
93+
"""Retrieves UASTs/files from the Lookout server and adjusts offsets for Unicode contents."""
9494

9595
def _unicodify_changes(get_changes):
9696
@functools.wraps(get_changes)

0 commit comments

Comments
 (0)