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

Add --plugins command-line option #11667

Open
GergelyKalmar opened this issue Dec 5, 2021 · 7 comments · May be fixed by #18104
Open

Add --plugins command-line option #11667

GergelyKalmar opened this issue Dec 5, 2021 · 7 comments · May be fixed by #18104
Labels
feature topic-configuration Configuration files and flags topic-plugins The plugin API and ideas for new plugins

Comments

@GergelyKalmar
Copy link

Feature

It seems that currently the only way to make mypy load a plugin is to add it to the configuration file as plugins = .... I would love if it would be possible to invoke mypy in the command line with or without a given plugin enabled. For example:

mypy --plugins=mypy_django_plugin.main,other_plugin:custom_entry_point ...

Pitch

The main benefit of this feature is that it would allow us to dynamically load plugins when invoking mypy using mypy.api.run or when invoking mypy using the command line. Currently it is difficult to programmatically "inject" a plugin into a mypy run, this change would make this much easier.

@sobolevn
Copy link
Member

sobolevn commented Dec 5, 2021

This might be problematic, because, for example, our plugin (mypy-django) requires extra configuration in mypy.ini. Loading it dynamically would just fail without this config.

@GergelyKalmar
Copy link
Author

That is true, however, configuration can also often be injected when necessary (see for example typeddjango/django-stubs#764 (comment) for one possibility with mypy-django). Also, configuration for "optional" plugins can still be kept in pyproject.toml, this would just allow one to choose during runtime whether to enable a given plugin or not.

@mawillcockson

This comment has been minimized.

@GergelyKalmar

This comment has been minimized.

@AlexWaygood AlexWaygood added topic-plugins The plugin API and ideas for new plugins topic-configuration Configuration files and flags labels Mar 27, 2022
@jp-larose
Copy link

Running into this issue right now where I want to specify a plugin in mypy.api.run, but it's not recognized.

@dibrinsofor
Copy link

Any work in this direction? I want to write tests with custom plugin options and this would be super helpful

@hauntsaninja
Copy link
Collaborator

PR welcome!

@dibrinsofor dibrinsofor linked a pull request Nov 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature topic-configuration Configuration files and flags topic-plugins The plugin API and ideas for new plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants