Skip to content
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

gh-104050: Argument Clinic: Annotate the BufferSeries class #106935

Merged
Merged
Changes from 2 commits
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
15 changes: 9 additions & 6 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
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
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
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
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()
ta.text.clear()
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down