Improve syntax error when brackets (parentheses) are mismatched
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu bằng cách xác định mã chẩn đoán của parser hoặc lỗi cú pháp xử lý các dấu ngoặc không khớp, sau đó tìm các kiểm thử hiện có cho những ví dụ được báo cáo. Cập nhật hành vi để chẩn đoán trỏ đến cả dấu ngoặc mở và dấu ngoặc đóng, đồng thời xác nhận các vị trí caret được hiển thị đối với các dấu ngoặc đơn trộn lẫn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The syntax error for mismatched brackets uses a caret to point to the closing bracket. But sometimes it is the opening bracket which is wrong. We should point a caret at both.
For example, this simple expression points to the closing square bracket:
>>> obj{"some long expression"]
File "<stdin>", line 1
obj{"some long expression"]
^
SyntaxError: closing parenthesis ']' does not match opening parenthesis '{'
But the real cause of the issue is the opening brace. It would be helpful to point at that as well:
obj{"some long expression"]
^ ^
SyntaxError: closing parenthesis ']' does not match opening parenthesis '{'
This is especially helpful in complex expressions with many mixed parentheses:
>>> obj[func(x[store[arg, a[i], b[j])])[y]]
File "<stdin>", line 1
obj[func(x[store[arg, a[i], b[j])])[y]]
^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
The reader has to carefully match up brackets by hand to see where the opening bracket is. A second caret would make that instantaneous:
obj[func(x[store[arg, a[i], b[j])])[y]]
^ ^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 558
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/cpython
-
docs pending
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
build type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
stdlib topic-email type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Tất cả issue của python/cpython
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
zostera/django-bootstrap4#894 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3276 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
zilliztech/memsearch#759 ·