Assertion failure crash with shadowed functools module: assert isinstance(singledispatch_obj, Instance)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu với mypy/plugins/singledispatch.py, đặc biệt là create_singledispatch_function_callback và assertion được hiển thị trong traceback. Tái hiện sự cố bằng cách lưu snippet được cung cấp dưới dạng functools.py và chạy mypy trên đó. Hoàn thành khi mô-đun functools bị shadow này không còn gây ra AssertionError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Crash Report
I noticed this crash when running mypy on the cpython codebase.
Traceback
Traceback (most recent call last):
File ".venv-mypy/bin/mypy", line 7, in <module>
sys.exit(console_entry())
File "mypy/mypy/__main__.py", line 15, in console_entry
main()
File "mypy/mypy/main.py", line 127, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "mypy/mypy/main.py", line 211, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "mypy/mypy/build.py", line 223, in build
result = _build(
File "mypy/mypy/build.py", line 302, in _build
graph = dispatch(sources, manager, stdout)
File "mypy/mypy/build.py", line 2953, in dispatch
process_graph(graph, manager)
File "mypy/mypy/build.py", line 3344, in process_graph
done, still_working = manager.wait_for_done(graph)
File "mypy/mypy/build.py", line 926, in wait_for_done
process_stale_scc(graph, next_scc, self)
File "mypy/mypy/build.py", line 3482, in process_stale_scc
graph[id].type_check_first_pass()
File "mypy/mypy/build.py", line 2341, in type_check_first_pass
self.type_checker().check_first_pass()
File "mypy/mypy/checker.py", line 530, in check_first_pass
self.accept(d)
File "mypy/mypy/checker.py", line 641, in accept
stmt.accept(self)
~~~~~~~~~~~^^^^^^
File "mypy/mypy/nodes.py", line 1164, in accept
return visitor.visit_decorator(self)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "mypy/mypy/checker.py", line 5466, in visit_decorator
self.visit_decorator_inner(e)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File "mypy/mypy/checker.py", line 5502, in visit_decorator_inner
sig, t2 = self.expr_checker.check_call(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
dec, [temp], [nodes.ARG_POS], e, callable_name=fullname, object_type=object_type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "mypy/mypy/checkexpr.py", line 1589, in check_call
return self.check_callable_call(
~~~~~~~~~~~~~~~~~~~~~~~~^
callee,
^^^^^^^
...<6 lines>...
object_type,
^^^^^^^^^^^^
)
^
File "mypy/mypy/checkexpr.py", line 1832, in check_callable_call
new_ret_type = self.apply_function_plugin(
callee,
...<7 lines>...
context,
)
File "mypy/mypy/checkexpr.py", line 1270, in apply_function_plugin
return callback(
FunctionContext(
...<8 lines>...
)
)
File "mypy/mypy/plugins/singledispatch.py", line 109, in create_singledispatch_function_callback
assert isinstance(singledispatch_obj, Instance)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError:
functools.py:4: : note: use --pdb to drop into pdb
To Reproduce
Save the following snippet as functools.py and run mypy on it:
def singledispatch(func):
pass
@singledispatch
def f(fn):
pass
Your Environment
- Mypy version used: 67df1163e5e2d197795811d8083da6afd13fb4f3
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.13.7
- Operating system and version: Arch Linux
- Ngôn ngữ chính
- Python
- Star
- 20.6k
- Fork
- 3.3k
- Merge trung bình
- 1 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 54
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python/mypy
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug topic-configuration topic-error-reporting
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Issue tương tự
-
link-check link-check:sphinx-theme
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
OpenHands/extensions#626 · 1 bình luận ·
-
Change observation tooltip text Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
CSCfi/sd-search-api#39 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100