Skip to content
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

AnnotationBear: Use unescaped_search_for #996

Merged
merged 1 commit into from
Nov 16, 2016
Merged

AnnotationBear: Use unescaped_search_for #996

merged 1 commit into from
Nov 16, 2016

Conversation

abh3po
Copy link
Member

@abh3po abh3po commented Nov 14, 2016

Fixes #993

@gitmate-bot
Copy link
Collaborator

Thanks for your contribution!

Reviewing pull requests take really a lot of time and we're all volunteers. Please make sure you go through the following check list and complete them all before pinging someone for a review.

As you learn things over your Pull Request please help others on the chat and on PRs to get their stuff right as well!

@aptrishu
Copy link
Member

aptrishu commented Nov 14, 2016

Your commit structure is not correct. see https://coala.io/commit.

@@ -4,6 +4,7 @@
from coalib.results.Result import Result, RESULT_SEVERITY
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find -> Find

Copy link
Member

@Nosferatul Nosferatul Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blank line before Fixes.. 😉

Copy link
Member Author

@abh3po abh3po Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh right, though this is a really awkward place for that review dont you think? ;) .
shouldn't it be on that main PR page?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw many times review like this

Copy link
Member Author

@abh3po abh3po Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well a line note (although i dont know if they still call it that), should be for that line only right? though occasionally i guess its fine, so i'll leave it there :P

text[position + 1:]))
except StopIteration:
end_match = None
print(end_match)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this? I don't know what should be printed when the bear is used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no we dont. Thanks!

text[position + 1:]))
except StopIteration:
end_match = None
end_end = position + end_match.span()[1] if end_match else -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If end match is none, then this will give an error saying span() not found in None

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, nevermind. Just saw the if

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be easier to just put the end_end calculation inside the try/cath. Why do another if?

unescaped_search_for("\n", text[position + 1:]))
except StopIteration:
newline_match = None
newline = position + newline_match.span()[1] if newline_match else -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same end position and newline can be inside the try/catch

Copy link
Member Author

@abh3po abh3po Nov 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they can't be right? they'll raise errors at different times and different behavior is expected at those times

@@ -287,4 +304,4 @@ class NoCloseError(Exception):

def __init__(self, annotation, code):
Exception.__init__(self, annotation + " has no closure")
self.code = code
self.code=code
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/bears/general/AnnotationBear.py
+++ b/bears/general/AnnotationBear.py
@@ -304,4 +304,4 @@

     def __init__(self, annotation, code):
         Exception.__init__(self, annotation + " has no closure")
-        self.code=code
+        self.code = code

unescaped_search_for("\n", text[position + 1:]))
newline = position + newline_match.span()[1]
except StopIteration:
newline = -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should put this try except construction into a function!

@sils
Copy link
Member

sils commented Nov 15, 2016

ok small change, big merge?

Find function doesn't ignore escape sequences
hence we use unescaped_search_for to ignore
the sequences which are escaped.

Fixes #993
@sils
Copy link
Member

sils commented Nov 16, 2016

ack e68e893

@sils
Copy link
Member

sils commented Nov 16, 2016

@rultor merge

@rultor
Copy link

rultor commented Nov 16, 2016

@rultor merge

@sils OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit e68e893 into master Nov 16, 2016
@rultor
Copy link

rultor commented Nov 16, 2016

@rultor merge

@sils Done! FYI, the full log is here (took me 2min)

@sils sils deleted the abhsag/anot branch November 16, 2016 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

7 participants