-
Notifications
You must be signed in to change notification settings - Fork 581
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
PyreBear.py: Add pyre-check bear #2689
Conversation
The tests |
Hi! @li-boxuan |
Sorry @atb00ker, you do not have the necessary permission levels to perform the action. |
Python 3.5.6 fail looks like it's because of an issue with |
|
tests/python/PyreBearTest.py
Outdated
# Check Result Lines & Columns | ||
lines = [result.affected_code[0] for result in results] | ||
# For Message #1 | ||
self.assertEqual(lines[0].end.column, 4) |
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 suspect this indicates that your bear is wrong. From the test file, it looks like their column number start from 0. So this should be 5 instead. Can you confirm if they use 0-based offset?
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.
Hi,
Running pyre without the bear reveals error in this format <file>:<row>:<column> <error>
.
Running the check on that file reveals:
pyre_bad.py:2:4 Incompatible return type [7]: Expected `int` but got `str`.
pyre_bad.py:6:4 Incompatible return type [7]: Expected `str` but got `int`.
So, i think it's correct. If you have any objection, please let me know.
Thanks
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.
Sorry if my review wasn't very clear. Take pyre_bad.py:2
for example.
return 'string'
pyre says the error happens on line 2, column 4.
Now the problem comes:
What is column 4? Is the first column numbered 0 or 1?
Back to our example. It is clear that there are 4 spaces before return
. Very likely, they consider the position of the first character of return
, as the error position, i.e. the position of r
. They call this position column 4
. If that is the case, we can infer that they count column numbers from 0. However, coala counts from 1. column 4
needs to be converted into column 5
in coala.
But I am not sure. I don't know how they come up with column 4
. Maybe they are referring to the last space before the word return
, but chances are small. Maybe they have inconsistencies/bugs within their tool. You need to look up in their documentation (or even code), or ask them in their community.
It might not be an easy task, but such 'tiny' thing is important. coala needs to be accurate: sometimes upstream linters are not accurate, and we detect problems and help solve them.
Let me know if my words are not clear enough 😉
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.
Oh, yes, it's clear now, thank you. 😄
Indeed, pyre is using 0-based offset for column and 1-based offset for row.
That should not be a problem, we can take the output from pyre and add 1
to column. I'll get to it as soon as possible.
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.
You can use a linter option to do that. See https://coala-api.netlify.com/developers/writing_linter_bears#normalize-line-or-column-numbers
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.
Perfect. Thanks for the help. 👍
@li-boxuan updated! 😄 |
@gitmate-bot rebase |
Hey! I'm GitMate.io! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost permanently |
Automated rebase with GitMate.io was successful! 🎉 |
See https://pyre-check.org/ for more info. | ||
""" | ||
LANGUAGES = {'Python', 'Python 3'} | ||
REQUIREMENTS = {PipRequirement('pyre-check', '0.0.12')} |
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.
CI is now complaining with Could not find a version that satisfies the requirement pyre-check~=0.0.12
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.
Do you mean appveyor
?
It's running python3.4
and as mentioned above, pyre-check is only available python3.5
or above, that's why it's failing.
Add PyreBear and Tests Closes #2487
Add PyreBear and Tests
Closes #2487
For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!
Checklist
them.
individually. It is not sufficient to have "fixup commits" on your PR,
our bot will still report the issues for the previous commit.) You will
likely receive a lot of bot comments and build failures if coala does not
pass on every single commit!
After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.
Please consider helping us by reviewing other peoples pull requests as well:
corobo mark wip <URL>
to get it outof the review queue.
The more you review, the more your score will grow at coala.io and we will
review your PRs faster!