Skip to content

Add the Zuban Type Checker #2067

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

davidhalter
Copy link

I have added the type checker that I have recently written. The results should be mostly the same, since it's mostly using the same tests.

I have only changed a few things:

  • I changed a few tests, mostly uncontroversial line change. I'm happy to revert these changes, but I feel like they all make sense and should not need much discussion.
  • I added a way to fill in conformance = "Pass" for unknown conformance if the automated tests pass. This was useful while adding the type checker and will probably be useful for other type checkers as well.
  • The seconds counter is one digit more precise if it's faster than a second.

I would be happy if this was merged soon, because the merge conflicts can be kind of annoying for this one.

@python-cla-bot
Copy link

python-cla-bot bot commented Aug 11, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@davidhalter
Copy link
Author

I just signed https://www.python.org/psf/contrib/contrib-form/, I hope that will fix CI eventually.

@JelleZijlstra
Copy link
Member

Thanks for adding this! I looked over the test file changes and they mostly look good, as noted above. I didn't review all the results for Zuban.

One concern: I know you're using a partly paid model, where some users have to pay for usage of the type checker. How does that system interact with usage of Zuban in this repo? For example, could we run into issues if the conformance suite grows past some line count, or if we tried to run all type checkers in CI?

@erictraut
Copy link
Collaborator

Thanks for adding this.

I didn't do a line-by-line review, but I did skim through it. I have a few questions:

  1. I noticed that many of the "Notes" fields in the Zuban results are identical to the "Notes" field for mypy. Is this correct? Unless Zuban is based on mypy directly (and is therefore bug-for-bug compatible), it seems unlikely that the conformance failure modes would be identical between the two type checkers.
  2. I noticed that some of the tests that were scored as "Partial" are missing a "Notes" field. For consistency, please provide a "Notes" field for all test cases that are not scored as "Pass". These notes appear in the conformance summary report when you mouse over a box that says "Partial".

@davidhalter
Copy link
Author

One concern: I know you're using a partly paid model, where some users have to pay for usage of the type checker. How does that system interact with usage of Zuban in this repo? For example, could we run into issues if the conformance suite grows past some line count, or if we tried to run all type checkers in CI?

No, I'm most likely going to open source it anyway in the near future and at the moment there the line count limits are disabled.

I noticed that many of the "Notes" fields in the Zuban results are identical to the "Notes" field for mypy. Is this correct? Unless Zuban is based on mypy directly (and is therefore bug-for-bug compatible), it seems unlikely that the conformance failure modes would be identical between the two type checkers.

It is based on Mypy's test suite, so if you look at the automatic test results and open them side by side you quite often see the exact same results. If the results are not the same the issues are sometimes still the same even if there is an additional error, it still stems from the same fact (e.g. some sort of thing is not supported, because it's not covered by Mypy's test suite).

I also specifically fixed the issues that would differ from Mypy's results to be more similar to Mypy, so I wouldn't have to write my own Notes. I'm lazy in a weird way :)

I noticed that some of the tests that were scored as "Partial" are missing a "Notes" field. For consistency, please provide a "Notes" field for all test cases that are not scored as "Pass". These notes appear in the conformance summary report when you mouse over a box that says "Partial".

I will add notes.

@srittau
Copy link
Collaborator

srittau commented Aug 12, 2025

I'm concerned about adding support for a type checker with a proprietary license. I'm volunteering my (and my company's) time for work on typing, and the contract has always been that the software we're directly supporting is licensed freely. For example, while we're directly supporting pyright, which is MIT licensed, we're not directly supporting the proprietary pylance language server. (Of course, we're indirectly supporting proprietary software and improving typing as a whole and fixing bugs reported by developers and users of proprietary software, but that benefits all typing users.)

Frankly speaking, if I'm supposed to support proprietary software, me or my company expects to be paid for it. So, I'm -1 on merging this (and any similar) PRs.

@davidhalter
Copy link
Author

@erictraut @JelleZijlstra I think I fixed the remaining issues.

@srittau Did you read the part about open sourcing?

@srittau
Copy link
Collaborator

srittau commented Aug 12, 2025

If Zuban would go Open Source, my concerns would obviously be irrelevant.

@davidhalter
Copy link
Author

Does anybody know why the CLA part of CI is still failing? I signed it yesterday.

@JelleZijlstra
Copy link
Member

I hoped that closing and reopening would fix the CLA issue but no dice. @ambv could you help take a look?

No, I'm most likely going to open source it anyway in the near future and at the moment there the line count limits are disabled.

That's good to know!

@srittau I broadly agree with this concern (and I probably wouldn't support adding Zuban to typeshed CI while it's still proprietary), but I think it's not too bad for the conformance suite, where we don't have to do that much more than run the type checker and record the results.

@brianschubert
Copy link
Member

I just signed https://www.python.org/psf/contrib/contrib-form/, I hope that will fix CI eventually.

It looks like the CLA form you signed requires manual processing, which probably hasn't gone through yet. The other way to sign the CLA is by clicking the button in the bot comment / visiting https://cla.python.org/, which is a fully automated process

@srittau
Copy link
Collaborator

srittau commented Aug 12, 2025

@srittau I broadly agree with this concern (and I probably wouldn't support adding Zuban to typeshed CI while it's still proprietary), but I think it's not too bad for the conformance suite, where we don't have to do that much more than run the type checker and record the results.

Fair enough, especially since I personally stay away from the conformance tests.

@davidhalter
Copy link
Author

@brianschubert Thanks that went through.
@srittau @JelleZijlstra I wouldn't even have tried to add Zuban to typeshed, because I know how much work that would be for you guys and appreciate what you are working on. I think here it's a bit different, but I doubt that matters in a few weeks.

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.

5 participants