internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: python/peps

Issue:
Incorrect rending of Martin von Löwis' name in the PEP index
If you look at https://www.python.org/dev/peps/ you will notice that for e.g. PEP 384, Martin's last name is rendered as "22. Löwis". It turns out the template has an `<ol>` tag that is set to start at 22 for part of Martin's last name.
```html
<ol class="first last loweralpha simple" start="22">
<li>Löwis</li>
</ol>
```


Discussion:

Resolving patch:
diff --git a/pep0/pep.py b/pep0/pep.py
--- a/pep0/pep.py
+++ b/pep0/pep.py
@@ -69,6 +69,9 @@ def __init__(self, author_and_email_tuple):
         name_sep = name.index(last_name_fragment)
         self.first = name[:name_sep].rstrip()
         self.last = last_name_fragment
+        if self.last[1] == u'.':
+            # Add an escape to avoid docutils turning `v.` into `22.`.
+            self.last = u'\\' + self.last
         self.suffix = suffix
         if not self.first:
             self.last_first = self.last


Test patch:
Repository: python/peps

Issue:
Change language from BDFL-Delegate to PEP-Delegate
The Steering Council feels that the term BDFL-Delegate is an anachronism, and the time has come to change the term to PEP-Delegate.  At a minimum, this work would have to happen:

* Mass updates to existing PEP texts for those PEPs that have a `BDFL-Delegate` field
* Update the PEP 0 [generation script](https://github.com/python/peps/blob/master/pep0/pep.py#L164) to recognize `PEP-Delegate` instead.

In the meantime, we will use the terms PEP-Delegate and BDFL-Delegate interchangeably.


Discussion:
Please see PR https://github.com/python/peps/pull/1672.

Resolving patch:
diff --git a/pep0/pep.py b/pep0/pep.py
--- a/pep0/pep.py
+++ b/pep0/pep.py
@@ -162,6 +162,7 @@ class PEP(object):
     headers = (('PEP', True), ('Title', True), ('Version', False),
                ('Last-Modified', False), ('Author', True),
                ('Sponsor', False), ('BDFL-Delegate', False),
+               ('PEP-Delegate', False),
                ('Discussions-To', False), ('Status', True), ('Type', True),
                ('Content-Type', False), ('Requires', False),
                ('Created', True), ('Python-Version', False),
diff --git a/pep2html.py b/pep2html.py
--- a/pep2html.py
+++ b/pep2html.py
@@ -219,7 +219,8 @@ def fixfile(inpath, input_lines, outfile):
     print('</td></tr></table>', file=outfile)
     print('<div class="header">\n<table border="0">', file=outfile)
     for k, v in header:
-        if k.lower() in ('author', 'bdfl-delegate', 'discussions-to', 'sponsor'):
+        if k.lower() in ('author', 'pep-delegate', 'bdfl-delegate', 'discussions-to',
+                         'sponsor'):
             mailtos = []
             for part in re.split(r',\s*', v):
                 if '@' in part:
@@ -401,7 +402,7 @@ def apply(self):
                 # empty
                 continue
             para = body[0]
-            if name in ('author', 'bdfl-delegate', 'sponsor'):
+            if name in ('author', 'bdfl-delegate', 'pep-delegate', 'sponsor'):
                 for node in para:
                     if isinstance(node, nodes.reference):
                         node.replace_self(peps.mask_email(node))
diff --git a/pep2pyramid.py b/pep2pyramid.py
--- a/pep2pyramid.py
+++ b/pep2pyramid.py
@@ -208,7 +208,7 @@ def fixfile(inpath, input_lines, outfile):
     print >> outfile, COMMENT
     print >> outfile, '<div class="header">\n<table border="0" class="rfc2822">'
     for k, v in header:
-        if k.lower() in ('author', 'bdfl-delegate', 'discussions-to'):
+        if k.lower() in ('author', 'bdfl-delegate', 'pep-delegate', 'discussions-to'):
             mailtos = []
             for part in re.split(',\s*', v):
                 if '@' in part:


Test patch:
Repository: python/peps

Issue:
"PEP numbers never change" verbiage is not in PEP 1
## Problem

The introduction to PEP 0 references PEP 1 as a source for

> PEP numbers are assigned by the PEP editors, and once assigned are never changed [1].

But PEP 1 doesn't say anything about PEP numbers never changing.

## Research

While skimming PEP 1, I found information about the PEP editor assigning a number:

> Once the PEP is ready for the repository, a PEP editor will:
Assign a PEP number (almost always just the next available number, but sometimes it's a special/joke number, like 666 or 3141). (Clarification: For Python 3, numbers in the 3000s were used for Py3k-specific proposals. But now that all new features go into Python 3 only, the process is back to using numbers in the 100s again. Remember that numbers below 100 are meta-PEPs.)

and

> The PEP editors are individuals responsible for managing the administrative and editorial aspects of the PEP workflow (e.g. assigning PEP numbers and changing their status). See PEP Editor Responsibilities & Workflow for details.

But I didn't find any reference to that number never changing. 

## Proposal:

Can we change PEP 0's introduction so that the reference is specific to assigning numbers?

```
PEP numbers are assigned by the PEP editors[1], and once assigned are never changed.
```

## Link

https://github.com/python/peps/blob/40ef5625b7d42655f49090ffd2c0860ecf8d1d9f/pep0/constants.py#L22-L27


Discussion:
Sounds good. Can you submit a PR?

Resolving patch:
diff --git a/pep0/constants.py b/pep0/constants.py
--- a/pep0/constants.py
+++ b/pep0/constants.py
@@ -21,8 +21,8 @@
 
 intro = """\
 This PEP contains the index of all Python Enhancement Proposals,
-known as PEPs.  PEP numbers are assigned by the PEP editors, and
-once assigned are never changed [1_].  The version control history [2_] of
+known as PEPs.  PEP numbers are assigned by the PEP editors[1_], and
+once assigned are never changed.  The version control history [2_] of
 the PEP texts represent their historical record.
 """
 


Test patch:
Repository: python/peps

Issue:
Change "Contents" to "Table of Contents" ? (Or delete it?)
Currently PEPs have a "mysterious" triangle pointing to the word "Contents". I don't know why, but somehow every time I see this I do a double take before I realize "oh, that's the ToC". Maybe spell "Table of Contents" in full? There should be plenty of horizontal space for that. (Not in the side bar though -- there mightn't be room for it, and there it's always expanded which provides enough context for the single word to be understood.)

Alternatively, why have this in the main body of the PEP at all when it's already in the sidebar?

(If there was a "nit" label I'd check it. :-)


Discussion:
> Currently PEPs have a "mysterious" triangle pointing to the word "Contents". I don't know why, but somehow every time I see this I do a double take before I realize "oh, that's the ToC". Maybe spell "Table of Contents" in full? 

Seems reasonable, especially given it is currently causing confusion. It appears to be used a handful of different places in the code, so not as a trivial as it should be, but not hard either.

> Alternatively, why have this in the main body of the PEP at all when it's already in the sidebar?

As discussed in #2364 that implemented the collapsed ToC, this was based on the consensus of the PEP 676 discussion on Discourse on that topic; I'd suggested removing it as it didn't seem to serve a clear purpose, but some people said they liked having it inline and making it a collapsible section seemed a decent compromise, as it didn't take up hardly any space. Also, we do need it on narrow widths/mobile, where the sidebar isn't shown (since we don't currently have a "hamburger menu" for navigation) so if we did elide it, what we would do is just hide it above the breakpoint where we show the sidebar.
Okay, collapsed ToC with heading "Table of Contents" seems reasonable enough.

Resolving patch:
diff --git a/pep_sphinx_extensions/pep_processor/html/pep_html_translator.py b/pep_sphinx_extensions/pep_processor/html/pep_html_translator.py
--- a/pep_sphinx_extensions/pep_processor/html/pep_html_translator.py
+++ b/pep_sphinx_extensions/pep_processor/html/pep_html_translator.py
@@ -91,7 +91,7 @@ def depart_label(self, node) -> None:
 
     def visit_bullet_list(self, node):
         if isinstance(node.parent, nodes.section) and "contents" in node.parent["names"]:
-            self.body.append("<details><summary>Contents</summary>")
+            self.body.append("<details><summary>Table of Contents</summary>")
             self.context.append("</details>")
         super().visit_bullet_list(node)
 


Test patch:
Repository: python/peps

Issue:
Links on topic pages are broken
If you go to a page like https://peps.python.org/topic/packaging/ and try to click on any of the PEPs, you get a github 404, and the URL is ``https://peps.python.org/topic/pep-0582``. 


Discussion:
The problem seems to be the following override:

https://github.com/python/peps/blob/0ffc78187c3b33d3ede64156dbf9e79f823ec116/pep_sphinx_extensions/__init__.py#L60


Resolving patch:
diff --git a/pep_sphinx_extensions/__init__.py b/pep_sphinx_extensions/__init__.py
--- a/pep_sphinx_extensions/__init__.py
+++ b/pep_sphinx_extensions/__init__.py
@@ -57,7 +57,7 @@ def _depart_maths():
 def _update_config_for_builder(app: Sphinx) -> None:
     app.env.document_ids = {}  # For PEPReferenceRoleTitleText
     if app.builder.name == "dirhtml":
-        app.env.settings["pep_url"] = "../pep-{:0>4}"
+        app.env.settings["pep_url"] = "/pep-{:0>4}"
 
     # internal_builder exists if Sphinx is run by build.py
     if "internal_builder" not in app.tags:
@@ -77,7 +77,7 @@ def _post_build(app: Sphinx, exception: Exception | None) -> None:
 def setup(app: Sphinx) -> dict[str, bool]:
     """Initialize Sphinx extension."""
 
-    environment.default_settings["pep_url"] = "pep-{:0>4}.html"
+    environment.default_settings["pep_url"] = "/pep-{:0>4}.html"
     environment.default_settings["halt_level"] = 2  # Fail on Docutils warning
 
     # Register plugin logic


Test patch:
Repository: python/peps

Issue:
Link topic page(s) in the rendered topic header
As a followup to #2579 implementing #2572 , it would be very useful to have the `Topic` header in the rendered PEPs actually link to said topic(s), and would be easy to implement (so long as we keep the display names consistent with the URLs, minus caps/whitespace).


Discussion:

Resolving patch:
diff --git a/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py b/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py
--- a/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py
+++ b/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py
@@ -98,6 +98,17 @@ def apply(self) -> None:
                     target = self.document.settings.pep_url.format(int(pep_str))
                     new_body += [nodes.reference("", pep_str, refuri=target), nodes.Text(", ")]
                 para[:] = new_body[:-1]  # drop trailing space
+            elif name == "topic":
+                new_body = []
+                for topic_name in body.astext().split(","):
+                    if topic_name:
+                        target = f"/topic/{topic_name.lower().strip()}/"
+                        new_body += [
+                            nodes.reference("", topic_name, refuri=target),
+                            nodes.Text(", "),
+                        ]
+                if new_body:
+                    para[:] = new_body[:-1]  # Drop trailing space/comma
             elif name in {"last-modified", "content-type", "version"}:
                 # Mark unneeded fields
                 fields_to_remove.append(field)


Test patch:
Repository: python/peps

Issue:
Superseded-By And Replaces link is bugged
See for example https://peps.python.org/pep-0509/.

The link to PEP 699 in the header points to a link relative to the the same document (which does not exist), instead of a link to another PEP.

Similarly, the `Replaces` link is bugged too https://peps.python.org/pep-0699/


Discussion:
@hugovk I suspect this is due to #2972.
Will check! 

Resolving patch:
diff --git a/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py b/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py
--- a/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py
+++ b/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py
@@ -131,6 +131,8 @@ def apply(self) -> None:
                 new_body = []
                 for pep_str in re.split(r",?\s+", body.astext()):
                     target = self.document.settings.pep_url.format(int(pep_str))
+                    if self.document.settings.builder == "dirhtml":
+                        target = f"../{target}"
                     new_body += [nodes.reference("", pep_str, refuri=target), nodes.Text(", ")]
                 para[:] = new_body[:-1]  # drop trailing space
             elif name == "topic":


Test patch:
Repository: python/peps

Issue:
Preview builds show wrong URLs (no trailing slash) in the index
IIUIC, this is an instance of #2420, but for preview builds, not the main site.

An example:
https://pep-previews--3320.org.readthedocs.build/
For PEP 1 it shows in the index: https://pep-previews--3320.org.readthedocs.build/pep-0001 (404)
https://pep-previews--3320.org.readthedocs.build/pep-0001/ - works fine


Discussion:

Resolving patch:
diff --git a/pep_sphinx_extensions/__init__.py b/pep_sphinx_extensions/__init__.py
--- a/pep_sphinx_extensions/__init__.py
+++ b/pep_sphinx_extensions/__init__.py
@@ -28,7 +28,7 @@ def _update_config_for_builder(app: Sphinx) -> None:
     app.env.document_ids = {}  # For PEPReferenceRoleTitleText
     app.env.settings["builder"] = app.builder.name
     if app.builder.name == "dirhtml":
-        app.env.settings["pep_url"] = "pep-{:0>4}"
+        app.env.settings["pep_url"] = "pep-{:0>4}/"
 
     app.connect("build-finished", _post_build)  # Post-build tasks
 
diff --git a/pep_sphinx_extensions/pep_zero_generator/writer.py b/pep_sphinx_extensions/pep_zero_generator/writer.py
--- a/pep_sphinx_extensions/pep_zero_generator/writer.py
+++ b/pep_sphinx_extensions/pep_zero_generator/writer.py
@@ -149,7 +149,7 @@ def write_pep0(
                 target = (
                     f"topic/{subindex}.html"
                     if builder == "html"
-                    else f"../topic/{subindex}"
+                    else f"../topic/{subindex}/"
                 )
                 self.emit_text(f"* `{subindex.title()} PEPs <{target}>`_")
                 self.emit_newline()


Test patch:
Repository: python/peps

Issue:
Infra: Allow dismissing the historical note banner
These notes take up more than a 1/3 of my screen and make it significantly harder to read the PEP. I can developer console it out of existence on my laptop, but not on my phone.


Discussion:
Example link: https://peps.python.org/pep-0654/

Perhaps another option is for the banner not to be sticky when the width and/or height of the browser is less than a given amount.

For example, it could never be sticky for mobile layouts.
@hugovk can I grab this
Feel free to submit a PR!

Resolving patch:
diff --git a/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py b/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py
--- a/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py
+++ b/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py
@@ -34,6 +34,9 @@ def run(self) -> list[nodes.admonition]:
         else:
             pre_text = self.admonition_pre_text
 
+        close_button_node = nodes.paragraph('', '', nodes.Text('×'), classes=['close-button'])
+        close_button_node['classes'].append('close-button')
+
         pre_text_node = nodes.paragraph(pre_text)
         pre_text_node.line = self.lineno
         pre_node, pre_msg = self.state.inline_text(pre_text, self.lineno)
@@ -50,6 +53,7 @@ def run(self) -> list[nodes.admonition]:
             "\n".join(source_lines), classes=["pep-banner"] + self.css_classes)
 
         admonition_node.append(pre_text_node)
+        admonition_node.append(close_button_node)
         if self.content:
             self.state.nested_parse(
                 self.content, self.content_offset, admonition_node)


Test patch:
Repository: TabbycatDebate/tabbycat

Issue:
Include average speaks in speaker standings/tab
Most people are quite bad at dividing large numbers by 4, 5, 9 etc. 

It would be useful if alongside (and probably on the left of all other scores), speaker tabs included a speaker's average.


Discussion:
This feature is actually already there—it's just an optional setting that tab directors can enable or disable, under the "Standings" group of the tournament configuration. (see: [options/preferences.py:543-575](https://github.com/TabbycatDebate/tabbycat/blob/v2.1.2/tabbycat/options/preferences.py#L543-L575))

But the default for BP is `['total']` in precedence because the WUDC constitution says to rank by total, and `['stdev']` in extra metrics (metrics that aren't used for ranking) (see: [options/presets.py:133-134](https://github.com/TabbycatDebate/tabbycat/blob/v2.1.2/tabbycat/options/presets.py#L133-L134)). So maybe we could just add `'average'` to extra metrics?

Resolving patch:
diff --git a/tabbycat/standings/teams.py b/tabbycat/standings/teams.py
--- a/tabbycat/standings/teams.py
+++ b/tabbycat/standings/teams.py
@@ -124,8 +124,8 @@ class TotalSpeakerScoreMetricAnnotator(TeamScoreQuerySetMetricAnnotator):
 class AverageSpeakerScoreMetricAnnotator(TeamScoreQuerySetMetricAnnotator):
     """Metric annotator for total speaker score."""
     key = "speaks_avg"
-    name = _("average speaker score")
-    abbr = _("ASS")
+    name = _("average total speaker score")
+    abbr = _("ATSS")
     exclude_forfeits = True
 
     function = Avg
@@ -165,6 +165,22 @@ class AverageMarginMetricAnnotator(TeamScoreQuerySetMetricAnnotator):
     exclude_forfeits = True
 
 
+class AverageIndividualScoreMetricAnnotator(TeamScoreQuerySetMetricAnnotator):
+    """Metric annotator for total constructive speaker score."""
+    key = "speaks_ind_avg"
+    name = _("average individual speaker score")
+    abbr = _("AISS")
+
+    def get_annotation(self, round=None):
+        annotation_filter = Q(
+            debateteam__teamscore__ballot_submission__confirmed=True,
+            debateteam__debate__round__stage=Round.STAGE_PRELIMINARY,
+            debateteam__teamscore__forfeit=False,
+            debateteam__speakerscore__position__lte=round.tournament.last_substantive_position
+        )
+        return Avg('debateteam__speakerscore__score', filter=annotation_filter)
+
+
 class DrawStrengthMetricAnnotator(BaseMetricAnnotator):
     """Metric annotator for draw strength."""
     key = "draw_strength"
@@ -349,6 +365,7 @@ class TeamStandingsGenerator(BaseStandingsGenerator):
         "wins"          : WinsMetricAnnotator,
         "speaks_sum"    : TotalSpeakerScoreMetricAnnotator,
         "speaks_avg"    : AverageSpeakerScoreMetricAnnotator,
+        "speaks_ind_avg": AverageIndividualScoreMetricAnnotator,
         "speaks_stddev" : SpeakerScoreStandardDeviationMetricAnnotator,
         "draw_strength" : DrawStrengthMetricAnnotator,
         "margin_sum"    : SumMarginMetricAnnotator,


Test patch:
Repository: TabbycatDebate/tabbycat

Issue:
Adjudicator popovers fail to generate with no descriptors
The affected code is the 'construct_popover' method (line 543 of utils/tables.py) - When an adjudicator has no descriptors (eg. if they're a solo chair which is unaffiliated with an institution), the descriptors array isn't converted to a string (line 556) and remains an array, which the resultant 'append' method (lines 558-561) can't handle.
This appears to cause public-facing draw pages to not load (even when displaying the public draw page from the admin interface).


Discussion:
Sentry issue: [BACKEND-Z0](https://sentry.io/tabbycat-ig/backend/issues/703084906/)

Resolving patch:
diff --git a/tabbycat/utils/tables.py b/tabbycat/utils/tables.py
--- a/tabbycat/utils/tables.py
+++ b/tabbycat/utils/tables.py
@@ -552,8 +552,7 @@ def construct_popover(adjs_data):
                     descriptors.append("<span class='text-danger'>in minority</span>")
                 text = a['adj'].name
 
-                if descriptors:
-                    descriptors = "(%s)" % (", ".join(descriptors))
+                descriptors = " (%s)" % (", ".join(descriptors)) if descriptors else ""
 
                 if self._show_record_links:
                     popover_data.append(self._adjudicator_record_link(descriptors, a['adj']))


Test patch:
Repository: TabbycatDebate/tabbycat

Issue:
Venue's Check-In Statuses page crashes
The "Venue's Check-In Statuses" page (Check-Ins -> Rooms' status) is empty, apart from the title element. Opening up devtools shows this error:

![image](https://user-images.githubusercontent.com/10998201/49333465-3ada3780-f5b7-11e8-8108-506d81922565.png)

Which points to this line:

![image](https://user-images.githubusercontent.com/10998201/49333471-57766f80-f5b7-11e8-9749-9fbd278a9d38.png)

This is a fresh installation on our own DigitalOcean server, and every other page works as expected. Running TabbyCat 2.2.7 on Ubuntu 18.04


Discussion:

Resolving patch:
diff --git a/tabbycat/checkins/views.py b/tabbycat/checkins/views.py
--- a/tabbycat/checkins/views.py
+++ b/tabbycat/checkins/views.py
@@ -43,8 +43,12 @@ class AssistantCheckInPreScanView(AssistantMixin, CheckInPreScanView):
 class BaseCheckInStatusView(TournamentMixin, TemplateView):
     template_name = 'checkin_status.html'
     scan_view = False
+    for_admin = True
 
     def get_context_data(self, **kwargs):
+
+        kwargs["for_admin"] = json.dumps(self.for_admin)
+
         events = get_unexpired_checkins(self.tournament, self.window_preference)
         kwargs["events"] = json.dumps([e.serialize() for e in events])
         if self.scan_view:
@@ -59,12 +63,7 @@ class CheckInPeopleStatusView(BaseCheckInStatusView):
 
     def get_context_data(self, **kwargs):
 
-        for_admin = True
-        if hasattr(self, '_user_role') and self._user_role == 'public':
-            for_admin = False
-        kwargs["for_admin"] = json.dumps(for_admin)
-
-        team_codes = use_team_code_names(self.tournament, admin=for_admin)
+        team_codes = use_team_code_names(self.tournament, admin=self.for_admin)
         kwargs["team_codes"] = json.dumps(team_codes)
 
         adjudicators = []
@@ -108,6 +107,7 @@ class AssistantCheckInPeopleStatusView(AssistantMixin, CheckInPeopleStatusView):
 
 
 class PublicCheckInPeopleStatusView(PublicTournamentPageMixin, CheckInPeopleStatusView):
+    for_admin = False
     public_page_preference = 'public_checkins'
 
 


Test patch: