Docformatter produces error when parsing docstring with Ruff noqa at the end
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
Tái hiện ví dụ docstring Python được cung cấp và theo dõi docformatter/format.py qua tokenize.untokenize, tập trung vào vị trí của các token xung quanh chú thích noqa ở cuối của Ruff. Được xem là hoàn tất khi việc định dạng hoàn thành mà không có ValueError và giữ nguyên chỉ thị noqa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When a docstring has a noqa directive at the end (used for suppressing one off linting errors in a docstring), docformatter throws an error.
Ex:
File:
"""
conf.py
~~~~~~~
Copyright (C) 2024 Noah Jenner under CC BY-SA 4.0.
To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/4.0/
------------------------------------------------------------------------
Configuration file for Sphinx.
""" # noqa: D205, D400
Error output:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\noahj\.local\bin\docformatter.exe\__main__.py", line 10, in <module>
sys.exit(main())
~~~~^^
File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\__main__.py", line 144, in main
return _main(
sys.argv,
...<2 lines>...
standard_in=sys.stdin,
)
File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\__main__.py", line 134, in _main
return formator.do_format_files()
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\format.py", line 649, in do_format_files
result = self._do_format_file(filename)
File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\format.py", line 815, in _do_format_file
formatted_source = self._do_format_code(source)
File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\format.py", line 876, in _do_format_code
_code = tokenize.untokenize(self.new_tokens)
File "C:\Users\noahj\AppData\Roaming\uv\data\python\cpython-3.14.2-windows-x86_64-none\Lib\tokenize.py", line 341, in untokenize
out = ut.untokenize(iterable)
File "C:\Users\noahj\AppData\Roaming\uv\data\python\cpython-3.14.2-windows-x86_64-none\Lib\tokenize.py", line 262, in untokenize
self.add_whitespace(start)
~~~~~~~~~~~~~~~~~~~^^^^^^^
File "C:\Users\noahj\AppData\Roaming\uv\data\python\cpython-3.14.2-windows-x86_64-none\Lib\tokenize.py", line 178, in add_whitespace
raise ValueError("start ({},{}) precedes previous end ({},{})"
.format(row, col, self.prev_row, self.prev_col))
ValueError: start (11,5) precedes previous end (12,0)
This occurs regardless of options passed into the command line.
Removing the directives does fix the problem, though this reintroduces linting errors produced by Ruff or other linters.
- Ngôn ngữ chính
- Python
- Star
- 598
- Fork
- 95
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 11
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 PyCQA/docformatter
-
1.7.8 crashes with a tokenize ValueError on a multi-line f-string inside parenthesesCó thể làm lại được @adityaanikam đã nhận 67 ngày trước và không có pull request nào đang mở. Đang mởC: convention P: bug U: high
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
PyCQA/docformatter#367 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its valueĐang mởC: convention P: bug U: high
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
PyCQA/docformatter#366 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
C: convention P: bug U: high
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
PyCQA/docformatter#345 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
C: convention P: bug U: high
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
PyCQA/docformatter#315 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
C: convention help wanted P: bug U: high
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
PyCQA/docformatter#285 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của PyCQA/docformatter
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ok-oldking/ok-wuthering-waves#1785 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
healthchecks/healthchecks#1349 ·
-
deployment release-lag
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
nolte/kamerplanter#2374 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/python-sdk#3725 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
batchterms() drops queries without a similar() clause, misaligning results with inputsCó thể đã có người làm @MohammadHijjawi97 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày