Skip to content

[stubsabot] Support diff analysis for GitLab hosted projects #14542

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

Merged
merged 3 commits into from
Aug 8, 2025

Conversation

brianschubert
Copy link
Member

Currently, stubsabot only does diff analysis for GitHub hosted projects. Typeshed has a few third-party stubs whose upstream projects are hosted on GitLab. It would be nice if stubsabot could do diff analysis for those too (having a "diff" URL in the PR body is especially handy).

Apparently GitLab has a REST API that works pretty similarly to GitHub's. It also doesn't appear to require an access token (at least for the /projects/:id endpoint, which is all this would need to use). I took a stab at updating stubsabot to use this API in a way that mirrors the current GitHub API use. It turned out to be pretty straightforward. This makes stubsabot do roughly the same diff analysis for GitLab projects that it does for GitHub projects, including adding a convenient diff URL to the PR body.

I tested this locally by downgrading one of the GitLab stubs (python-crontab) and then running python3 scripts/stubsabot.py --action-level local python-crontab. It seems to be working well. This is the commit message was generated:

[stubsabot] Bump python-crontab to 3.3.*

Release: https://pypi.org/pypi/python-crontab/3.3.0
Homepage: https://gitlab.com/doctormo/python-crontab/
Repository: https://gitlab.com/doctormo/python-crontab
Typeshed stubs: https://github.com/python/typeshed/tree/main/stubs/python-crontab
Diff: https://gitlab.com/doctormo/python-crontab/-/compare/v3.2.0...v3.3.0

Stubsabot analysis of the diff between the two releases:

  • 0 public Python files have been added.
  • 0 files included in typeshed's stubs have been deleted.
  • 2 files included in typeshed's stubs have been modified or renamed: cronlog.py, crontab.py.
  • Total lines of Python code added: 52.
  • Total lines of Python code deleted: 40.

If stubtest fails for this PR:

  • Leave this PR open (as a reminder, and to prevent stubsabot from opening another PR)
  • Fix stubtest failures in another PR, then close this PR

Note that you will need to close and re-open the PR in order to trigger CI

Co-authored-by: Semyon Moroz <donbarbos@proton.me>
@brianschubert
Copy link
Member Author

brianschubert commented Aug 7, 2025

Thanks for the review! I've incorporated your suggestions

(I re-tested the latest commit locally; scripts/stubsabot.py runs successfully for bumping both GitHub and GitLab projects)

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks mostly good, remarks below.

@AlexWaygood
Copy link
Member

I definitely don't want to block this PR, especially now that you've already done the work -- but just for reference, we previously discussed doing something like this in #9792. I'm a bit wary of adding too much complexity to this script, given that it doesn't have any tests; we need to balance the benefits changes like this have with the maintenance burden of the stubsabot script itself.

@srittau
Copy link
Collaborator

srittau commented Aug 8, 2025

For me, the benefits of this PR greatly outweigh the maintenance burden. Whenever a Gitlab hosted package changes, I need to relearn how to do diffs in Gitlab. IIRC, the last time I even cloned the repository and then did a local diff, since this was faster than finding the relevant function in Gitlab.

@AlexWaygood
Copy link
Member

Sounds good!

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
@srittau srittau merged commit 10dba69 into python:main Aug 8, 2025
6 checks passed
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.

4 participants