Skip to content

Commit

Permalink
merged and solve the conflits. All tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Mema5 committed Feb 25, 2020
1 parent 6d56f17 commit 14e8ce0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
9 changes: 1 addition & 8 deletions tests/test_checker/test_noqa.py
Expand Up @@ -163,15 +163,8 @@
'WPS354': 1,
'WPS355': 1,
'WPS356': 1,
<<<<<<< HEAD
<<<<<<< HEAD
'WPS357': 0, # logically unacceptable.
=======
'WPS357': 1,
>>>>>>> test: added a test for violation WPS357. A raw string must contain the '\' character. If there is no '\' in the string a raw string should not be used.
=======
'WPS357': 1,
>>>>>>> fix: repaired build a priori, issue #9
'WPS358': 1,

'WPS400': 0, # defined in ignored violations.
'WPS401': 0, # logically unacceptable.
Expand Down
Expand Up @@ -3,10 +3,10 @@
import pytest

from wemake_python_styleguide.violations.consistency import (
RawStringNotNeededViolation,
WrongMultilineStringViolation,
)
from wemake_python_styleguide.visitors.tokenize.primitives import (
RawStringNotNeededViolation,
WrongStringTokenVisitor,
)

Expand Down
12 changes: 7 additions & 5 deletions wemake_python_styleguide/violations/consistency.py
Expand Up @@ -2139,7 +2139,7 @@ class LineCompriseCarriageReturnViolation(TokenizeViolation):
Solution:
Use only ``\n`` (not ``\r\n`` or ``\r``) to break lines.
.. versionadded:: 0.15.0
.. versionadded:: 0.14.0
"""

Expand All @@ -2149,10 +2149,12 @@ class LineCompriseCarriageReturnViolation(TokenizeViolation):

@final
class RawStringNotNeededViolation(TokenizeViolation):
"""
Summary here.
r"""
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.
Solution:
Do not prefix the string with r. Use a normal string instead.
Expand All @@ -2162,9 +2164,9 @@ class RawStringNotNeededViolation(TokenizeViolation):
# Wrong:
r'This string should not be prefixed with r.'
Example::
Examples here.
.. versionadded:: 0.15.0
"""

error_template = 'Error template here'
Expand Down
2 changes: 1 addition & 1 deletion wemake_python_styleguide/visitors/tokenize/primitives.py
Expand Up @@ -239,7 +239,7 @@ def _check_unnecessary_raw_string(self, token: tokenize.TokenInfo) -> None:
if 'r' in modifiers.lower():
if '\\' not in string_def:
self.add_violation(
RawStringNotNeededViolation(token),
consistency.RawStringNotNeededViolation(token),
)


Expand Down

0 comments on commit 14e8ce0

Please sign in to comment.