New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forbid to use \r in line breaks #1111
Labels
help wanted
Extra attention is needed
level:starter
Good for newcomers
rule request
Adding a new rule
Milestone
Comments
sobolevn
added
help wanted
Extra attention is needed
level:starter
Good for newcomers
rule request
Adding a new rule
labels
Jan 18, 2020
My researchTesting before writing code: import io
import tokenize
from textwrap import dedent
def factory(code: str):
lines = io.StringIO(dedent(code))
return list(tokenize.generate_tokens(lambda: next(lines))) And using it: >>> factory('1 + 2\r\n')
[TokenInfo(type=2 (NUMBER), string='1', start=(1, 0), end=(1, 1), line='1 + 2\r\n'), TokenInfo(type=54 (OP), string='+', start=(1, 2), end=(1, 3), line='1 + 2\r\n'), TokenInfo(type=2 (NUMBER), string='2', start=(1, 4), end=(1, 5), line='1 + 2\r\n'), TokenInfo(type=4 (NEWLINE), string='\r\n', start=(1, 5), end=(1, 7), line='1 + 2\r\n'), TokenInfo(type=0 (ENDMARKER), string='', start=(2, 0), end=(2, 0), line='')] Here we go! We can create And test it in https://github.com/wemake-services/wemake-python-styleguide/tree/master/tests/test_visitors/test_tokenize |
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 21, 2020
…se rule check and test script
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 21, 2020
… CHANGELOG.md in this case
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 22, 2020
…nor processing
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 22, 2020
…nor processing [step2]
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 22, 2020
…nor processing [step3]
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 22, 2020
…ecord for new #noqa violation in #/tests/test_checker/test_noqa.py
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 22, 2020
…#noqa violation and it Count in #/tests/test_checker/test_noqa.py
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 23, 2020
…#noqa violation and chng it's Count to Zero in #/tests/test_checker/test_noqa.py
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 23, 2020
…line Violation(code=357) in #/violations/consistency.py
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 23, 2020
…n #/visitors/tokenize/syntax.py
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 23, 2020
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 23, 2020
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 23, 2020
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 23, 2020
…able in #/visitors/tokenize/syntax.py
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 24, 2020
…sitors/tokenize/syntax.py (locally tested OK)
sobolevn
added a commit
that referenced
this issue
Feb 24, 2020
* Issue #1111 - Forbid to use \r in line breaks: Made base rule check and test script * Issue #1111 - Forbid to use \r in line breaks: updated CHANGELOG.md in this case * Issue #1111 - Forbid to use \r in line breaks: some minor processing * Issue #1111 - Forbid to use \r in line breaks: some minor processing [step2] * Issue #1111 - Forbid to use \r in line breaks: some minor processing [step3] * Issue #1111 ~~~: [step4] 'Repair test' by update WPS-record for new #noqa violation in #/tests/test_checker/test_noqa.py * Issue #1111 ~~~: [step5] by update WPS-record for new #noqa violation and it Count in #/tests/test_checker/test_noqa.py * Issue #1111 ~~~: [step6] by update WPS-record for new #noqa violation and chng it's Count to Zero in #/tests/test_checker/test_noqa.py * Issue #1111 ~~~: [step7] change sort order with CR-newline Violation(code=357) in #/violations/consistency.py * Issue #1111: fixed logical mistake with if-condition in #/visitors/tokenize/syntax.py * Issue #1111: add new condition in #/visitors/tokenize/syntax.py * Issue #1111: add new condition in #/visitors/tokenize/syntax.py * Issue #1111: add new condition in #/visitors/tokenize/syntax.py * Issue #1111: removed excess condition with 'line' variable in #/visitors/tokenize/syntax.py * Issue #1111: add new condition with token.line in #/visitors/tokenize/syntax.py (locally tested OK) * Fixes build Co-authored-by: ilia shb <45450122+jigi-33@users.noreply.github.com>
jigi-33
added a commit
to jigi-33/wemake-python-styleguide
that referenced
this issue
Feb 25, 2020
* Issue wemake-services#1111 - Forbid to use \r in line breaks: Made base rule check and test script * Issue wemake-services#1111 - Forbid to use \r in line breaks: updated CHANGELOG.md in this case * Issue wemake-services#1111 - Forbid to use \r in line breaks: some minor processing * Issue wemake-services#1111 - Forbid to use \r in line breaks: some minor processing [step2] * Issue wemake-services#1111 - Forbid to use \r in line breaks: some minor processing [step3] * Issue wemake-services#1111 ~~~: [step4] 'Repair test' by update WPS-record for new #noqa violation in #/tests/test_checker/test_noqa.py * Issue wemake-services#1111 ~~~: [step5] by update WPS-record for new #noqa violation and it Count in #/tests/test_checker/test_noqa.py * Issue wemake-services#1111 ~~~: [step6] by update WPS-record for new #noqa violation and chng it's Count to Zero in #/tests/test_checker/test_noqa.py * Issue wemake-services#1111 ~~~: [step7] change sort order with CR-newline Violation(code=357) in #/violations/consistency.py * Issue wemake-services#1111: fixed logical mistake with if-condition in #/visitors/tokenize/syntax.py * Issue wemake-services#1111: add new condition in #/visitors/tokenize/syntax.py * Issue wemake-services#1111: add new condition in #/visitors/tokenize/syntax.py * Issue wemake-services#1111: add new condition in #/visitors/tokenize/syntax.py * Issue wemake-services#1111: removed excess condition with 'line' variable in #/visitors/tokenize/syntax.py * Issue wemake-services#1111: add new condition with token.line in #/visitors/tokenize/syntax.py (locally tested OK) * Fixes build Co-authored-by: ilia shb <45450122+jigi-33@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
help wanted
Extra attention is needed
level:starter
Good for newcomers
rule request
Adding a new rule
Rule request
Thesis
Forbid to use
\r
in your line breaks.Related:
https://github.com/openstack/hacking/blob/master/hacking/checks/other.py#L23-L34
Reasoning
It is hard to catch and requires special tools for it.
The text was updated successfully, but these errors were encountered: