Add support for per-plugin options
还没有人认领这个 Issue。
评估
调研方向
The issue names no implementation files, entry points, or tests. Start by reviewing the three configuration proposals and the existing plugin registration and option-parsing behavior, then establish which convention is accepted and how plugin options and the mypy version should be exposed before defining completion criteria.
由索引模型根据 Issue 内容生成。
描述
Starting discussion from #3517 in a new issue.
Some plugins may want to expose user-configurable options. For example, with my docstring parser I want users to be able to specify which style of docstrings to expect (the default behavior of automatic discovery is a bit slower).
To accomplish this we define a convention for plugins to provide options within mypy.ini, and pass the parsed options as Dict[str, str] to the plugin() registration function, along with the mypy version. User plugins will need to do their own conversion of options from str to bool, int, float, etc.
Here are three proposals for how to link plugin registration with per-plugin configuration options:
Option A
The correlation here is bit fragile and the per-plugin section headers may be difficult to grok for longer (i.e. absolute) paths:
[mypy]
fast_parser = true
plugins = /path/to/typeddict.py, /path/to/mypydoc.py
[mypy.plugins-/path/to/mypydoc.py]
docstring_style = 'google'
Option B
The following is visually clean, but can't as easily piggy-back on the current options-parsing code. (Note: I believe that mypy-plugins with a dash would conflict with mypy's per-module configuration):
[mypy]
fast_parser = true
[mypy.plugins]
typeddict = /path/to/typeddict.py
mypydoc = /path/to/mypydoc.py
[mypy.plugins-mypydoc]
docstring_style = 'google'
Option C
The following dotted registration style is used heavily by mercurial, and this is what I decided on in my implementation. It piggy-backs existing options parsing code, so it could easily be extended to per-module options in the future, if we found a need for that:
[mypy]
fast_parser = true
plugins.typeddict = /path/to/typeddict.py
plugins.mypydoc = /path/to/mypydoc.py
[mypy.plugins-mypydoc]
docstring_style = 'google'
I tried to come up with some logic for the separators:
- periods join known mypy sections: e.g.
[mypy],[mypy.plugins] - dashes join sections with dynamic topics: e.g.
[mypy.plugins-custom.plugin],[mypy-custom.module]
I'm completely open to other suggestions. Underscore could work in place of periods, but I found it less visually appealing.
- 主要语言
- Python
- 星标
- 20.6k
- 派生
- 3.3k
- 平均合并
- 1 天 18 小时
- 30 天内合并 PR
- 54
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python/mypy 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
-
documentation
难度 2/5 1-3 小时 新手友好度 72/100
-
bug topic-configuration topic-error-reporting
难度 2/5 1-3 小时 新手友好度 68/100
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
bug
难度 2/5 1-3 小时 新手友好度 86/100
zostera/django-bootstrap4#894 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
use-agent-os/agent-os#3276 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#117848 ·