-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Feature
Provide the full parsed config file to each plugin
Pitch
Currently, Mypy plugins are passed only the Options object in their constructor, which captures Mypy options but not Mypy plugin options. Consequently, each plugins has to re-parse the file. This is a waste of time, may add to the necessary dependencies for a plugin with configuration, and requires re-implementing the logic for parsing different file types (TOML vs config). Here's an example of the pydantic plugin doing just this:
The neatest solution would be to pass the full config object to the constructor. Unfortunately, this would be a breaking change to the constructor signature, so probably the more palatable option would be to store the config options within each Plugin instance (in the constructor), which the subclasses can use if they want:
class SomeMypyPlugin(Plugin):
def __init__(self, options: Options) -> None:
super().__init__(options)
my_config_option = self.raw_config["tools"]["some_mypy_plugin"]
# use my_config_option