-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Plugins? #607
Comments
No, not currently. I'm reluctant to add plugin support at this time for several reasons: 1) Pyright is still changing at a rapid pace, and a plugin system would create a constraint that would prevent certain changes, 2) type support within the Python language has improved significantly since mypy was originally developed, so most (although still not all) cases can be handled without custom extensions, 3) philosophically, I'd prefer to continue to push for improving the Python standard and the adoption of this standard within third-party libraries rather than encouraging library-specific non-standard behaviors. I'm open to revisiting this in the future (say, in a year). Out of curiosity, what use case are you interested in? |
I am interested in this 🙂 We have lots of
I would love to add extra typecheckers that would do the same thing as |
One year has passed, are there any news on this feature? 🙂 Some context, why I am asking about it: I have several quite complex |
We've spent some time on this. Here's what I can say at this point: We will not be providing a proprietary plug-in model akin to the one provided by mypy. There are too many problems with such a model. It doesn't work across type checkers, maintenance of plugins is a problem, distribution and installation of plugins is a problem (since users need to know they exist and how to configure them), and there are potential security issues with plugins that are downloaded and run on users' machines. Instead, we've started to look at ways to cover the most common reasons why mypy plugins are written today. This is what led to this proposal, which is implemented in pyright today and supports several popular libraries (pydantic, attrs, etc.) that previously required mypy plugins. Our preference is to find declarative forms to describe type semantics rather than imperative code used, for example, in mypy plugins. If there are patterns similar to dataclass_transform that you think would have general utility across multiple libraries and could form the basis for an official language extension (in the form of a ratified PEP), we'd be interested in your thoughts. In general, we want to encourage authors of new Python libraries (or new versions of existing Python libraries) to take into account static type checking when designing their interface contracts. Non-standard semantics and dynamic behaviors are antithetical to static type checking and work against efforts to improve the Python coding experience with tools such as language servers and type checkers. |
I think there are cases where a plugin system would still be beneficial. For me the big problem is Odoo. Someone has developed a closed-source (unfortunately) VS Code extension here that is implemented on top of Pyright to support all of Odoo's mechanisms, and the side effect is that the author also recommends disabling the regular Pyright extension in Odoo projects. It would have been so much better if Pyright was simply extensible instead. I am not a developer of Odoo itself (I only develop addons) so I can't speak into all of the technical reasons why the developers chose to design Odoo the way it is. But one thing is clear: Odoo philosophy revolves around making the system extensible, and this design goal seems to be what has led to many of the static type checker incompatibilities. If you want to understand why it would be impossible to accomplish the extensibility Odoo provides while being totally "pythonic" and supporting static type checkers, you'll have to do a bit of reading to understand what Odoo's addon system does that is not possible with Python's built-in inheritance mechanisms. Here are a few suggestions: |
Since the link is dead: This is now https://peps.python.org/pep-0681/. |
The thing is plugins are not always about extra typing and when they are it may be because some local code changes. An example of the first is filtering pyright messages to changed lines or functions only as opposed to the whole changed files. The whole files makes migration impossible for us now because of walls of warnings for each PR. Second situation happens when say you add a custom middleware to Django, which adds some attributes to |
@Suor, I understand there are benefits to plugins. They also come with very significant downsides. We made the decision long ago not to support plugins in pyright, and we're going to stand by that decision. Our strategy is to continue to participate in extending the Python type system so more patterns are supported. |
Does there currently exist any way of extending pyright akin to the plugin system that is offered by mypy?
The text was updated successfully, but these errors were encountered: