-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Running mypy on doctests #7966
Comments
Using a mypy plugin hook for this may be an option, though no existing hook seems to fit the bill. The existing API may be enough to get the right kind of output however. One idea would be to include empty lines to align line numbers. Another idea would be to have a postprocessing step that translates the files names in mypy output. It's a bit hacky, but it has the benefit of working right now. |
I did both (align numbers and translate file names) here. It ain't great (it still uses temporary files), but it works. Bear in mind that I only spent a couple hours hacking this together, so reserve judgment. Improvements are likely many and obvious. Suggestions are invited.
Help is built in:
|
Hi!
I am trying to make a custom tool to run
mypy
on doctests inside my project.Because I want to be sure that my examples are correct. And since
pytest
/doctest
modules do it with ease I am seeking the similar solution but for types. Examples, where I need this:So, I have started with using
api
. It works fine, but requires to create temp files with extracteddoctest
code contents. This is a working solution, but the only ugly part is that it is based on temporary files. And reports incorrect filenames, locations, etc.I have tried to go deeper and pass just the source code /
ast
parts. But, it does not look like it works this way. Is there a way to make it work without touching a lot of protected / private APIs?Maybe this can be implemented in
mypy
itself at sometime?Thanks!
The text was updated successfully, but these errors were encountered: