Skip to content

[red-knot] Add 'mypy_primer' workflow#16554

Merged
sharkdp merged 4 commits intomainfrom
david/mypy-primer
Mar 10, 2025
Merged

[red-knot] Add 'mypy_primer' workflow#16554
sharkdp merged 4 commits intomainfrom
david/mypy-primer

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Mar 7, 2025

Summary

Run Red Knot on a small selection of ecosystem projects via a forked version of mypy_primer. I think it's probably fine to run this from a fork as long as the red knot CLI is not stable, and as long as we're still experimenting with this?

There's probably a lot still to do both on the mypy_primer side as well as on the pipeline side here (we might want to have it comment on PRs, for example), but maybe this is a good first step to have this as a non-blocking pipeline that simply runs on red knot PRs? For you to look at, if you're interested...

Example output with a negative diff for a dummy change (commented out unresolved-attribute diagnostics):

image

Test Plan

@sharkdp sharkdp added the ty Multi-file analysis & type inference label Mar 7, 2025
@sharkdp sharkdp force-pushed the david/mypy-primer branch 12 times, most recently from 70ef66a to 9d5799d Compare March 7, 2025 16:49
@sharkdp sharkdp marked this pull request as ready for review March 7, 2025 16:55
--type-checker knot \
--old base_commit \
--new "$GITHUB_SHA" \
--project-selector '/(arrow|black|bandersnatch|twine)$' \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a few hand-selected projects that we don't panic on 🙃. I will look into extending this list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did so now and went through the project list again. I chose a few projects without a lot of dependencies, because we do not understand -stubs imports yet.

@MichaReiser
Copy link
Member

This is only an understanding question from my side: The check doesn't comment on the PR, unlike Ruff's ecosystem check. Anyone interested would have to "actively" check the results. Is that understanding correct?

@sharkdp
Copy link
Contributor Author

sharkdp commented Mar 7, 2025

This is only an understanding question from my side: The check doesn't comment on the PR, unlike Ruff's ecosystem check. Anyone interested would have to "actively" check the results. Is that understanding correct?

Yes, see PR description: "There's probably a lot still to do […] (we might want to have it comment on PRs, for example), but maybe this is a good first step to have this as a non-blocking pipeline that simply runs on red knot PRs? For you to look at, if you're interested..."

Mypy, pyright, and typeshed all have similar pipelines (see e.g. https://github.com/python/mypy/blob/master/.github/workflows/mypy_primer.yml and https://github.com/python/mypy/blob/master/.github/workflows/mypy_primer_comment.yml), so we should be able to set this up easily once we're confident that it has an actual benefit. I just thought it would make sense to run this "in the background" in the beginning to experiment with it.

@MichaReiser
Copy link
Member

MichaReiser commented Mar 7, 2025

Ruff's ecosystem also supports this. There are two parts to it:

The main downside is that GitHub has an upper limit on the comment size :(

Either way. I think this is useful as it is. It being invisible has the downside that it's unlikely that people will check it, unless we introduce a I did review the red knot ecosystem changes checkbox to the test plan

@sharkdp sharkdp force-pushed the david/mypy-primer branch from 9d5799d to 80384c5 Compare March 10, 2025 09:03
@sharkdp
Copy link
Contributor Author

sharkdp commented Mar 10, 2025

Either way. I think this is useful as it is. It being invisible has the downside that it's unlikely that people will check it, unless we introduce a I did review the red knot ecosystem changes checkbox to the test plan

I mainly wanted to keep it in the background for a few days(?) to test it before we start commenting on everyone's PRs.

@sharkdp sharkdp force-pushed the david/mypy-primer branch from 80384c5 to 57004d5 Compare March 10, 2025 09:06
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

This is cool and a very nise surprise for the new month :)

@MichaReiser MichaReiser added the ci Related to internal CI tooling label Mar 10, 2025
permissions: {}

on:
pull_request:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe consider moving it to the ci.yaml? It's where we have all (or the vast majority) of all jobs that run as part of pull requests and is the first place where I'd be looking for this job

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did consider moving it there, but kept it in a separate file for now because (1) I still consider it experimental; I'm not even sure if we want to go with mypy_primer for our ecosystem checks or build something of our own and (2) I wanted to keep it close to the existing mypy_primer pipelines that exist for mypy/pyright/typeshed.

I would definitely be in favor of moving it to ci.yaml if this turns out to be the approach we want to take.

@sharkdp sharkdp merged commit 36d12ce into main Mar 10, 2025
22 checks passed
@sharkdp sharkdp deleted the david/mypy-primer branch March 10, 2025 10:14
dcreager added a commit that referenced this pull request Mar 10, 2025
* main:
  [red-knot] Add support for calling `type[…]` (#16597)
  Update migration guide with the new `ruff.configuration` (#16567)
  [red-knot] Add 'mypy_primer' workflow (#16554)
  Update Rust crate indoc to v2.0.6 (#16585)
  Update Rust crate syn to v2.0.100 (#16590)
  Update Rust crate thiserror to v2.0.12 (#16591)
  Update Rust crate serde_json to v1.0.140 (#16589)
  Update Rust crate quote to v1.0.39 (#16587)
  Update Rust crate serde to v1.0.219 (#16588)
  Update Rust crate proc-macro2 to v1.0.94 (#16586)
  Update Rust crate anyhow to v1.0.97 (#16584)
  Update dependency ruff to v0.9.10 (#16593)
  Update Rust crate unicode-ident to v1.0.18 (#16592)
  [red-knot] Do not ignore typeshed stubs for 'venv' module (#16596)
  [red-knot] Reduce Salsa lookups in `Type::find_name_in_mro` (#16582)
  Fix broken red-knot property tests (#16574)
  [red-knot] Consistent spelling of "metaclass" and "meta-type" (#16576)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Related to internal CI tooling ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants