Semantic analyzer confuses a function with a module
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 20.6k
- Fork
- 3.3k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
The following code creates a package structure that demonstrates what I think is a bug in mypy's new semantic analyzer.
from os import makedirs
makedirs('src/core')
makedirs('src/stuff')
open('src/__init__.py', 'w').write("""
# nothing here
""")
open('src/core/__init__.py', 'w').write("""
from .run import config
""")
open('src/core/run.py', 'w').write("""
from ..stuff import somefunction
config = None
somefunction()
""")
open('src/stuff/__init__.py', 'w').write("""
from .somemore import more
from .somefunction import somefunction
""")
open('src/stuff/somefunction.py', 'w').write("""
def somefunction():
print("Hello, World!")
""")
open('src/stuff/somemore.py', 'w').write("""
def more():
from ..core import config
""")
When checking the created src package with mypy 0.720 and Python 3.7, I get the following error:
src/core/run.py:6: error: Module not callable
What mypy thinks is a module is actually a function. It just has the same name as its containing module.
When I check with --no-new-semantic-analyzer, I do not get this error.
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.
Hướng nghiên cứu
Tạo lại gói src được sinh từ nội dung issue và chạy mypy 0.720 có và không có --no-new-semantic-analyzer, tập trung vào src/core/run.py và src/stuff/somefunction.py. Truy tìm lý do somefunction được phân giải thành một module thay vì một hàm có thể gọi; hoàn tất khi semantic analyzer mới chấp nhận lời gọi và hành vi này được bao phủ bởi một regression test.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- compilers
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100