mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Recommend disabling explicit-string-concatenation
(#2366)
If `allow-multiline = false` is set, then if the user enables `explicit-string-concatenation` (`ISC003`), there's no way for them to create valid multiline strings. This PR notes that they should turn off `ISC003`. Closes #2362.
This commit is contained in:
parent
8963a62ec0
commit
5f07e70762
4 changed files with 13 additions and 3 deletions
|
@ -1054,7 +1054,7 @@ For more, see [flake8-implicit-str-concat](https://pypi.org/project/flake8-impli
|
|||
| Code | Name | Message | Fix |
|
||||
| ---- | ---- | ------- | --- |
|
||||
| ISC001 | single-line-implicit-string-concatenation | Implicitly concatenated string literals on one line | |
|
||||
| ISC002 | multi-line-implicit-string-concatenation | Implicitly concatenated string literals over continuation line | |
|
||||
| ISC002 | multi-line-implicit-string-concatenation | Implicitly concatenated string literals over multiple lines | |
|
||||
| ISC003 | explicit-string-concatenation | Explicitly concatenated string should be implicitly concatenated | |
|
||||
|
||||
### flake8-import-conventions (ICN)
|
||||
|
@ -2933,6 +2933,11 @@ By default, implicit concatenations of multiline strings are
|
|||
allowed (but continuation lines, delimited with a backslash, are
|
||||
prohibited).
|
||||
|
||||
Note that setting `allow-multiline = false` should typically be coupled
|
||||
with disabling `explicit-string-concatenation` (`ISC003`). Otherwise,
|
||||
both explicit and implicit multiline string concatenations will be seen
|
||||
as violations.
|
||||
|
||||
**Default value**: `true`
|
||||
|
||||
**Type**: `bool`
|
||||
|
|
|
@ -649,7 +649,7 @@
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"allow-multiline": {
|
||||
"description": "Whether to allow implicit string concatenations for multiline strings. By default, implicit concatenations of multiline strings are allowed (but continuation lines, delimited with a backslash, are prohibited).",
|
||||
"description": "Whether to allow implicit string concatenations for multiline strings. By default, implicit concatenations of multiline strings are allowed (but continuation lines, delimited with a backslash, are prohibited).\n\nNote that setting `allow-multiline = false` should typically be coupled with disabling `explicit-string-concatenation` (`ISC003`). Otherwise, both explicit and implicit multiline string concatenations will be seen as violations.",
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
|
|
|
@ -24,6 +24,11 @@ pub struct Options {
|
|||
/// By default, implicit concatenations of multiline strings are
|
||||
/// allowed (but continuation lines, delimited with a backslash, are
|
||||
/// prohibited).
|
||||
///
|
||||
/// Note that setting `allow-multiline = false` should typically be coupled
|
||||
/// with disabling `explicit-string-concatenation` (`ISC003`). Otherwise,
|
||||
/// both explicit and implicit multiline string concatenations will be seen
|
||||
/// as violations.
|
||||
pub allow_multiline: Option<bool>,
|
||||
}
|
||||
|
||||
|
|
|
@ -1855,7 +1855,7 @@ define_violation!(
|
|||
impl Violation for MultiLineImplicitStringConcatenation {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
format!("Implicitly concatenated string literals over continuation line")
|
||||
format!("Implicitly concatenated string literals over multiple lines")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue