Skip to content
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

fixes for unittest.runner #13205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fixes for unittest.runner #13205

wants to merge 1 commit into from

Conversation

tungol
Copy link
Contributor

@tungol tungol commented Dec 6, 2024

I have a MR for stubtest out at python/mypy#18251. One of the things that got flagged was unittest.runner.TextTestRunner.resultclass and I was having a hard time figuring it out. I made a version of unittest/runner.py locally that had all of our existing stub annotations inline with the actual code, and ran mypy on that to try and figure it out. This is various fixes that were needed to make mypy satisfied with that version of the file.

  • Updating _ResultClassType to use TextTestResult[Any]: This was the primary issue that got flagged in my MR for stubtest.
  • _WritelnDecorator takes _SupportsWriteAndFlush as the argument. It is _TextTestStream, which adds writeln on top of that, but it doesn't need to be passed something that already has writeln.
  • writeln doesn't actually return anything
  • durations is an integer which indexes into unittest.result._DurationsType, not unittest.result._DurationsType itself. It's TestResult.collectedDurations that is _DurationsType.
  • TextTestRunner.warnings is passed to warnings.simplefilter, which is typed for literals.

Copy link
Contributor

github-actions bot commented Dec 6, 2024

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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.

1 participant