check_code broken

Sergey Trupp avatarSergey Trupp created an issue


Given "" flake8.main.check_file("test") -> return 9 test errors flake8.main.check_code(open(r"").read()) -> return "0" as output

win 7 64x, flake8 –version installed by pip ... 2.0 (pep8: 1.4.5, pyflakes: 0.6.1, mccabe: 0.2)

Comments (4)

  1. Ian Cordasco

    Using the following I can sort of reproduce this:

    import os
    import sys

    With check_code I get:

    stdin:1:10: W292 no newline at end of file
    stdin:1:23: E901 SyntaxError: invalid syntax
    stdin:2:11: W292 no newline at end of file

    With check_file: F401 'os' imported but unused

    I'll take care of figuring out why this is reporting two different things. Thanks for the report

  2. Sergey Trupp

    hi, i found the bug. in the check_code function you do call "lines=code.splitlines()". this is wrong because splitlines remove line breaks ... you should call "code.splitlines(True)"

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.