| 17 | ISSUE_URI = "https://bugs.python.org/issue?@action=redirect&bpo={0}" |
| 18 | |
| 19 | def run(self) -> tuple[list[Element], list[nodes.system_message]]: |
| 20 | issue = self.text |
| 21 | |
| 22 | # sanity check: there are no bpo issues within these two values |
| 23 | if 47_261 < int(issue) < 400_000: |
| 24 | msg = self.inliner.reporter.error( |
| 25 | f"The BPO ID {issue!r} seems too high. " |
| 26 | "Use :gh:`...` for GitHub IDs.", |
| 27 | line=self.lineno, |
| 28 | ) |
| 29 | prb = self.inliner.problematic(self.rawtext, self.rawtext, msg) |
| 30 | return [prb], [msg] |
| 31 | |
| 32 | issue_url = self.ISSUE_URI.format(issue) |
| 33 | refnode = nodes.reference(issue, f"bpo-{issue}", refuri=issue_url) |
| 34 | self.set_source_info(refnode) |
| 35 | return [refnode], [] |
| 36 | |
| 37 | |
| 38 | class GitHubIssue(SphinxRole): |