Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-104050: Argument Clinic: Annotate BufferSeries
  • Loading branch information
erlend-aasland committed Jul 20, 2023
commit 07d41a0e98eae3bc4340f4f677c0c03b0d81a89a
13 changes: 8 additions & 5 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,12 +1965,15 @@ class BufferSeries:
e.g. o[-1] is an element immediately preceding o[0].
"""

def __init__(self):
def __init__(self) -> None:
self._start = 0
self._array = []
self._array: list[_TextAccumulator] = []
self._constructor = _text_accumulator

def __getitem__(self, i):
def __getitem__(
self,
i: int
) -> _TextAccumulator:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not write it in one line? It is still pretty short.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure; I have not yet developed a preference when it comes to annotation style :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I agree with Serhiy — I would probably put this all on one line — but I also don't really care much either way (life's too short to spend it arguing over code formatting preferences 😄)

Copy link
Copy Markdown
Contributor Author

@erlend-aasland erlend-aasland Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(life's too short to spend it arguing over code formatting preferences 😄)

No, it isn't! 😆

i -= self._start
if i < 0:
self._start += i
Expand All @@ -1981,11 +1984,11 @@ def __getitem__(self, i):
self._array.append(self._constructor())
return self._array[i]

def clear(self):
def clear(self) -> None:
for ta in self._array:
ta._text.clear()

def dump(self):
def dump(self) -> str:
texts = [ta.output() for ta in self._array]
return "".join(texts)

Expand Down