From 08c50b372b7f1064cd28440a7d10f7f4b93782bb Mon Sep 17 00:00:00 2001 From: "fabian.waldner@gmail.com" Date: Sun, 23 Feb 2020 14:43:51 +0100 Subject: [PATCH 1/2] documentation: Added documentation for the violation RawStringNotNeededViolation (WPS357). Follows the general structure for documentation. Relates to original issue #1081. Closes #11 --- .../violations/consistency.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/wemake_python_styleguide/violations/consistency.py b/wemake_python_styleguide/violations/consistency.py index 6aadc5c4e..9841301f8 100644 --- a/wemake_python_styleguide/violations/consistency.py +++ b/wemake_python_styleguide/violations/consistency.py @@ -2113,20 +2113,25 @@ class IterableUnpackingViolation(ASTViolation): @final class RawStringNotNeededViolation(TokenizeViolation): - """ - Summary here. + r""" + Forbid the use of raw strings when there is no backslash in the string. Reasoning: - Reasoning here. + Raw string are only needed when dealing with \' in the string. Solution: - Solution here. + Do not prefix the string with r. Use a normal string instead. Example:: - Examples here. + # Correct: + s = r'This is a correct use \' + + # Wrong: + s = r'This string should not be prefixed with r.' .. versionadded:: 0.13.0 + """ - error_template = 'Error template here' + error_template = 'Found an unnecessary use of a raw string' code = 357 From 544ae5c9b42f6a0fbedd66292bb09230c9181e61 Mon Sep 17 00:00:00 2001 From: "fabian.waldner@gmail.com" Date: Sun, 23 Feb 2020 15:07:14 +0100 Subject: [PATCH 2/2] fix: Removed an unnecessary single quotation mark in the documentation relates to #11 --- wemake_python_styleguide/violations/consistency.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wemake_python_styleguide/violations/consistency.py b/wemake_python_styleguide/violations/consistency.py index 9841301f8..0fe3842db 100644 --- a/wemake_python_styleguide/violations/consistency.py +++ b/wemake_python_styleguide/violations/consistency.py @@ -2117,7 +2117,7 @@ class RawStringNotNeededViolation(TokenizeViolation): Forbid the use of raw strings when there is no backslash in the string. Reasoning: - Raw string are only needed when dealing with \' in the string. + Raw string are only needed when dealing with \ in the string. Solution: Do not prefix the string with r. Use a normal string instead.