Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/youtube.py (Python)

Code before:
    def _comment_entries(self, root_continuation_data, identity_token, account_syncid, session_token_list, parent=None):

        def extract_thread(parent_renderer):
            contents = try_get(parent_renderer, lambda x: x['contents'], list) or []

            for content in contents:
                if not isinstance(content, dict):
                    continue
                comment_thread_renderer = try_get(content, lambda x: x['commentThreadRenderer'])
                comment_renderer = try_get(content, (lambda x: x['commentThreadRenderer']['comment']['commentRenderer'],
                                                     lambda x: x['commentRenderer']), dict)
                if not comment_renderer:
                    continue
                comment = self._comment_entry(comment_renderer, parent)
                if not comment:
                    continue
                yield comment
                # Attempt to get the replies
                comment_replies_renderer = try_get(comment_thread_renderer,
                        lambda x: x['replies']['commentRepliesRenderer'], dict)

                if comment_replies_renderer:
                    comment_entries_iter = self._comment_entries(comment_replies_renderer,
                           identity_token, account_syncid, parent=comment.get('id'),
                           session_token_list=session_token_list)

                    for reply_comment in comment_entries_iter:
                        yield reply_comment

        headers = self._DEFAULT_BASIC_API_HEADERS.copy()

        if identity_token:
            headers['x-youtube-identity-token'] = identity_token

        if account_syncid:
            headers['X-Goog-PageId'] = account_syncid
            headers['X-Goog-AuthUser'] = 0

        continuation = YoutubeTabIE._extract_continuation(root_continuation_data)  # TODO
        first_continuation = False
        if parent is None:
            first_continuation = True

        for page_num in itertools.count(not int(first_continuation)):
            if not continuation:
                break
            retries = self._downloader.params.get('extractor_retries', 3)
            count = -1
            last_error = None

            while count < retries:

Review comment (suggestion):
Linter allows either

```py
comment_entries_iter = self._comment_entries(
    comment_replies_renderer,
    identity_token, account_syncid, parent=comment.get('id'),
    session_token_list=session_token_list)
```

or 

```py
comment_entries_iter = self._comment_entries(comment_replies_renderer,
                                             identity_token, account_syncid, parent=comment.get('id'),
                                             session_token_list=session_token_list)
```

I prefer the former, but chose whichever you like

Code after:
                         session_token_list, parent=None, comment_counts=None):

        def extract_thread(parent_renderer):
            contents = try_get(parent_renderer, lambda x: x['contents'], list) or []
            if not parent:
                comment_counts[2] = 0
            for content in contents:
                comment_thread_renderer = try_get(content, lambda x: x['commentThreadRenderer'])
                comment_renderer = try_get(
                    comment_thread_renderer, (lambda x: x['comment']['commentRenderer'], dict)) or try_get(
                    content, (lambda x: x['commentRenderer'], dict))

                if not comment_renderer:
                    continue
                comment = self._extract_comment(comment_renderer, parent)
                if not comment:
                    continue
                comment_counts[0] += 1
                yield comment
                # Attempt to get the replies
                comment_replies_renderer = try_get(
                    comment_thread_renderer, lambda x: x['replies']['commentRepliesRenderer'], dict)

                if comment_replies_renderer:
                    comment_counts[2] += 1
                    comment_entries_iter = self._comment_entries(
                        comment_replies_renderer, identity_token, account_syncid,
                        parent=comment.get('id'), session_token_list=session_token_list,
                        comment_counts=comment_counts)

                    for reply_comment in comment_entries_iter:
                        yield reply_comment

        if not comment_counts:
            # comment so far, est. total comments, current comment thread #
            comment_counts = [0, 0, 0]
        headers = self._DEFAULT_BASIC_API_HEADERS.copy()

        # TODO: Generalize the download code with TabIE
        if identity_token:
            headers['x-youtube-identity-token'] = identity_token

        if account_syncid:
            headers['X-Goog-PageId'] = account_syncid
            headers['X-Goog-AuthUser'] = 0

        continuation = YoutubeTabIE._extract_continuation(root_continuation_data)  # TODO
        first_continuation = False
        if parent is None:
            first_continuation = True