Mypy 1.6.1 fails with returns 0.21.0 on use of `curry.partial`
还没有人认领这个 Issue。
评估
调研方向
从 returns/contrib/mypy/_features/partial.py 和 returns/contrib/mypy/_typeops/inference.py 开始,尤其关注 traceback 中显示的调用。使用 Python 3.11.4、returns 0.21.0 和 mypy 1.6.1 重现该故障,然后检查相关的 mypy plugin API 更改。当 curry.partial 示例能够在没有 TypeError 的情况下运行,并显示预期的 callable 类型时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Bug report
I think mypy 1.6 has broken your plugin again. It seems like their API changes quite a lot. :(
What's wrong
my_partial = returns.curry.partial(foo, bar=baz(1))
reveal_type(my_partial)
Running mypy 1.6.1 against this, with the plugin installed and activated, results in:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.6.1
Traceback (most recent call last):
File "mypy/checkexpr.py", line 5374, in accept
File "mypy/nodes.py", line 1907, in accept
File "mypy/checkexpr.py", line 452, in visit_call_expr
File "mypy/checkexpr.py", line 581, in visit_call_expr_inner
File "mypy/checkexpr.py", line 1420, in check_call_expr_with_callee_type
File "mypy/checkexpr.py", line 1514, in check_call
File "mypy/checkexpr.py", line 1734, in check_callable_call
File "mypy/checkexpr.py", line 1194, in apply_function_plugin
File "*/.venv/lib/python3.11/site-packages/returns/contrib/mypy/_features/partial.py", line 67, in analyze
).new_partial()
^^^^^^^^^^^^^
File "*/.venv/lib/python3.11/site-packages/returns/contrib/mypy/_features/partial.py", line 135, in new_partial
partial = self._create_partial_case(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "*/.venv/lib/python3.11/site-packages/returns/contrib/mypy/_features/partial.py", line 167, in _create_partial_case
).from_usage(self._applied_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "*/.venv/lib/python3.11/site-packages/returns/contrib/mypy/_typeops/inference.py", line 61, in from_usage
constraints = self._infer_constraints(applied_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "*/.venv/lib/python3.11/site-packages/returns/contrib/mypy/_typeops/inference.py", line 83, in _infer_constraints
constraints = infer_constraints_for_callable(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: infer_constraints_for_callable() missing required argument 'context' (pos 6)
How is that should be
path/to/execution.py:21: note: Revealed type is "def (id: builtins.str, df: Any, *, schema: Union[builtins.str, None] =) -> FooBarBaz"
System information
-
pythonversion: 3.11.4 -
returnsversion: 0.21.0 -
mypyversion: 1.6.1 -
pytestversion (if any): 7.2.1
- 主要语言
- Python
- 星标
- 4.4k
- 派生
- 154
- 平均合并
- 3 小时 5 分钟
- 30 天内合并 PR
- 22
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dry-python/returns 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 48/100
dry-python/returns#2394 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 52/100
dry-python/returns#2365 ·
-
难度 5/5 一周以上 新手友好度 25/100
dry-python/returns#2355 · 1 条评论 ·
-
bug
难度 4/5 3-5 天 新手友好度 45/100
dry-python/returns#2295 · 4 条评论 · 1 个 reaction ·
-
bug
难度 4/5 3-5 天 新手友好度 45/100
dry-python/returns#2253 · 2 条评论 ·
查看 dry-python/returns 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 70/100
huggingface/Repo2RLEnv#163 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
难度 2/5 1-3 小时 新手友好度 70/100
NousResearch/hermes-agent#121143 ·