Skip to content

Commit

Permalink
Add error suppression hint for multi-line strings (#9205)
Browse files Browse the repository at this point in the history
Closes #9200.
  • Loading branch information
charliermarsh committed Dec 20, 2023
1 parent bc0bf6f commit f5d4019
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ use crate::settings::LinterSettings;
/// """
/// ```
///
/// ## Error suppression
/// Hint: when suppressing `W505` errors within multi-line strings (like
/// docstrings), the `noqa` directive should come at the end of the string
/// (after the closing triple quote), and will apply to the entire string, like
/// so:
///
/// ```python
/// """Lorem ipsum dolor sit amet.
///
/// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
/// """ # noqa: W505
/// ```
///
/// ## Options
/// - `task-tags`
/// - `pycodestyle.max-doc-length`
Expand Down
15 changes: 14 additions & 1 deletion crates/ruff_linter/src/rules/pycodestyle/rules/line_too_long.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,24 @@ use crate::settings::LinterSettings;
/// )
/// ```
///
/// ## Error suppression
/// Hint: when suppressing `E501` errors within multi-line strings (like
/// docstrings), the `noqa` directive should come at the end of the string
/// (after the closing triple quote), and will apply to the entire string, like
/// so:
///
/// ```python
/// """Lorem ipsum dolor sit amet.
///
/// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
/// """ # noqa: E501
/// ```
///
/// ## Options
/// - `line-length`
/// - `pycodestyle.max-line-length`
/// - `task-tags`
/// - `pycodestyle.ignore-overlong-task-comments`
/// - `pycodestyle.max-line-length`
///
/// [PEP 8]: https://peps.python.org/pep-0008/#maximum-line-length
#[violation]
Expand Down

0 comments on commit f5d4019

Please sign in to comment.