-
Notifications
You must be signed in to change notification settings - Fork 121
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
Use python tokenizer to identify single-line comments and docstrings. #106
Conversation
7c585d5
to
79548fd
Compare
Ciao @rubik . I was having trouble performing a raw analyze on a codebase so I rewrote much of the comment recognizing code from an early PR. In particular, the code I was having a problem with looked like this:
There is some existing code that tries to recognize the position of '=' in multi-line string assignments that makes assumptions that may not always be the case. I have replaced this code with code that uses the python tokenizer to recognize strings and comments rather than using a custom parser. I've also tried to reduce the number of times radon parses the code to a single time. I have only changed one existing test case, which appeared to be expecting the wrong number of blank lines. I'm assuming we should count lines as blank whether or not they are inside multi-line strings. Please let me know what I can do to get this into the codebase. Thank you. |
@@ -187,7 +187,7 @@ def fib(n): | |||
""" | |||
if n <= 1: return 1 # otherwise it will melt the cpu | |||
return fib(n - 2) + fib(n - 1) | |||
''', (6, 9, 10, 2, 3, 1, 1)), | |||
''', (6, 9, 10, 2, 3, 2, 1)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that '2' is the correct value for number of blank lines in this code. I think previously the line in the multiline string had been excluded.
1 similar comment
2 similar comments
220ab6b
to
1305669
Compare
1 similar comment
Perform the raw analysis using a single iterator. Add test cases that cover line continuations and unusual docstrings.
1305669
to
5f05f1b
Compare
2 similar comments
Thanks Andrew! I'll review this tomorrow but at a cursory glance it looks good. The code you provided definitely crashes the analysis, so something will have to be done for sure. |
Sorry for the delay Andrew! The PR looks good and I'm merging it. Thanks again! |
Thanks @rubik . Please let me know if there are any reported issues with this change. I'll be happy to try to fix them. |
Perform the raw analysis using a single iterator.
Add test cases that cover line continuations and unusual docstrings.