Skip to content

Close PRs from new contributors that do not follow PR template - #116

Draft
TiloRC wants to merge 2 commits into
sympy:masterfrom
TiloRC:template-2
Draft

TiloRC wants to merge 2 commits into
sympy:masterfrom
TiloRC:template-2

Conversation

@TiloRC

@TiloRC TiloRC commented Jul 31, 2026

Copy link
Copy Markdown

References to other Issues or PRs

sympy/sympy#29289

https://groups.google.com/g/sympy/c/Tx_yg8NxP5U/m/gu_9mZhLCgAJ

Brief description of what is fixed or changed

Enforces the PR template for new contributors:

  • Checks that all markdown section headings are present and unmodified.
  • Checks that the AI disclosure and brief description sections are not empty.
  • Checks to see that all of the markdown comments from the template are present and unmodified.

AI Generation Disclosure

All the code is AI written, but I have looked through it carefully and understand it. I have not tested to see if works yet though.

Comment thread sympy_bot/webapp.py Outdated
Comment thread sympy_bot/webapp.py Outdated
Comment thread sympy_bot/tests/test_webapp.py
Comment thread sympy_bot/tests/test_pr_template.py Outdated
TiloRC and others added 2 commits July 30, 2026 19:00
Add sympy_bot/pr_template.py with a pure validate_pr_template(pr_desc)
function (mirroring get_changelog) that checks a PR description against
the SymPy pull request template. The checks are independent functions in
a CHECKS list so more can be added later:

- all required section headings are present verbatim,
- every HTML comment from the template is kept verbatim (deleting or
  rewriting them is a signal of AI-generated text), and
- the Brief description and AI Generation Disclosure sections are
  non-empty.

The canonical template is embedded as PR_TEMPLATE (the single source of
truth) and the required comment strings are derived from it so they
can't drift.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add close_pr_if_bad_template, called from pull_request_edited only when a
first-time contributor (author_association FIRST_TIME_CONTRIBUTOR or
FIRST_TIMER) opens a PR. If the description doesn't follow the pull
request template, the bot posts a comment explaining what's wrong and
closes the PR, directing the author to open a new one with the same
changes (a closed PR can't be reopened by the author). Compliant PRs and
PRs from established contributors are untouched.

Update the shared description fixtures in test_webapp.py to be
template-compliant (derived from PR_TEMPLATE) so the existing release
notes tests still pass, and add tests for the new handler and its gating.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@TiloRC

TiloRC commented Jul 31, 2026

Copy link
Copy Markdown
Author

I've been thinking about it more and it's probably not a good idea to have the bot close people's PRs as that's annoying. And there actually aren't that many people that break the rules now that we're not in GSoC application season. (Here's a visualization claude made of how many PRs have lacked the AI disclosure statement or left it empty in 2026).

It would probably be better to just have the bot leave a comment telling people to include it.

@TiloRC TiloRC closed this Jul 31, 2026
@asmeurer

Copy link
Copy Markdown
Member

I think we should reconsider this. People can reopen the PR once they fix the template.

@TiloRC

TiloRC commented Sep 10, 2026

Copy link
Copy Markdown
Author

People can reopen the PR once they fix the template.

I don't think that's true. I believe if someone else closes their PR they can't reopen it (unless they're a maintainer).

We probably should have the bot leave a comment though. Maybe the bot could flag such PRs with a label to make it easy to identify which PRs are violating the rules?

@TiloRC TiloRC reopened this Sep 10, 2026
@moorepants

Copy link
Copy Markdown
Member

I believe if someone else closes their PR they can't reopen it (unless they're a maintainer).

Yes, that is correct. They have to make a new PR if they are not a maintainer.

@asmeurer

Copy link
Copy Markdown
Member

The bot could reopen the PR if it is fixed. I don't know if that works for checks (are checks run for closed PRs?), but it's easy for the PR description check.

Comment thread sympy_bot/pr_template.py
# truth for this module. To update the checks when the upstream template
# changes, replace the text below with the new contents of
# https://github.com/sympy/sympy/blob/master/.github/PULL_REQUEST_TEMPLATE.md
PR_TEMPLATE = '''\

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.

I don't think we should duplicate the template here. That is just going to be annoying every time we update the template in SymPy. The bot should be able to pull in the template using the github file API pretty easily.

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.

(and indeed if we do merge this we'll want to add something to the top of the template stating that the headings are all required and the PR will be closed automatically if they aren't filled out)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants