Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

RFC: improve diagnostic formatting

Đang mở
#3,258 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
20/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
cli

Hướng nghiên cứu

Start by reading the existing handling for --caret-diagnostic, -C/-A/-B, interactive mode, and --stdin_single_line; the issue does not name files or tests. Decide whether to introduce --format, which output formats and context behavior it should support, and how the interactive and stdin cases should work. Done means the discussion settles these design questions before implementation.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

awaiting review enhancement

In #3256 I introduced the --caret-diagnostic flag in order to report the diagnostic message as it is done by modern compilers.
The name of the flag is derived from https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fcaret-diagnostics (though I missed the ending s).

@peternewman suggested to add a --format flag, instead, in order to be future proof.

Since this requires more changes to the current code, I would like to open a discussion about the best strategy.
The main problem is how the context (-C/-A/-B) is applied. Here is an example:

:     with fp:
:         # GH-87235: On macOS all file descriptors for /dev/fd/N share the same
>         # file offset, reset the file offset after scanning the zipfile diretory
:         # to not cause problems when some runs 'python3 /dev/fd/9 9<some_script'
:         start_offset = fp.tell()
Lib/zipimport.py:355: diretory ==> directory

This works only when there is one line.

--format flag

Introducing the --format flag has the advantage that we know how many context source lines are printed by a format, so with -C/-A/-B the code only needs to print additional lines around the lines printed by the format.

Possible formats:

plain (default)
if filename != "-":
    f"{cfilename}:{cline}: {cwrongword} "
    f"==> {crightword}{creason}"
else:
    f"{cline}: {cwrongword} ==> {crightword}{creason}"

Not sure if ccolumn can be added.

diagnostic / caret-diagnostics / develop/ ?
if filename != "-":
       f"{cfilename}:{cline}:{ccolumn}: {cwrongword} "
       f"==> {crightword}{creason}\n"
       f"{line}"
       f"{ccaret}\n"                   
else:
       f"{cfilename}:{cline}:{ccolumn}: {cwrongword} "
       f"==> {crightword}{creason}\n"
       f"{line}"
       f"{ccaret}\n"

TODO

Not sure if the code in interactive mode should also be modified. Example:

:         env['LC_ALL'] = 'C'
>         # Empty strings will be quoted by popen so we should just ommit it
:         if args != ('',):
        # Empty strings will be quoted by popen so we should just ommit it
	ommit ==> omit (Y/n)

The same line is printed twice; not sure if it is a good user experience.

Another issue I found is:

elif options.stdin_single_line:
    print(f"{cline}: {cwrongword} ==> {crightword}{creason}")
else:
    print(
        f"{cline}: {line.strip()}\n\t{cwrongword} "
        f"==> {crightword}{creason}"
    )

Should we have the second template be an alternative format?
Should the --stdin_single_line flag be removed before the next release?

Thanks.

Ngôn ngữ chính
Python
Star
2.4k
Fork
531
Merge trung bình
15 giờ 5 phút
Pull request đã merge (30 ngày)
18

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codespell-project/codespell

Tất cả issue của codespell-project/codespell

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.