-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use MyPy for inlay type hints #69
Comments
Hi, thanks for your suggestion. This is maybe possible to implement using a feature that mypy added recently - dmypy inspect. However I don't think I'll have time to do that. Contributions are welcome. |
It seems not possible at the moment to use |
We looked at this with a friend a while ago and came to the same conclusion. Inlay hints are done through the language server, which in this case is Pylance. And we can't really change what Pylance shows in the inlay hints. |
Yes, that seems possible. |
Does vscode support multiple language servers at once? Alternatively, does Pylance support plugins? |
Pylance seems to be closed source and doesn't support any plugins, something like basedpyright might be an option if you want to integrate this functionality into an existing language server. VSCode should be able to run multiple language servers at once, e.g Ruff recently implemented a language server. |
An extension can provide inlay hints with or without a language server. vscode also supports multiple inlay hints extensions for the same language. In short, there is no limitation on the vscode side. The harder part is pulling this information out of mypy. |
Is it possible on a technical level for this extension to overwrite the inlay type hints from Pylance (Pyright) with ones from MyPy? If so, would you consider this to be a feature worth implementing?
The reason why I would like this feature personally is because I use MyPy for typing but VS Code's Python language server, Pylance, shows hover and inlay hints from Pyright, which is a lot of the time different from MyPy. This makes it confusing when trying to keep the code MyPy valid. An example where this is an issue is:
The inlay hint shows the type revealed from Pylance, which when typing with MyPy in mind gives the wrong impression of the type.
I was considering posting this feature request directly to the Pylance repository, but since Pylance's whole point is that it is based on it's own type checker I thought that this extension implementing it would be a better fit.
The text was updated successfully, but these errors were encountered: