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

PyreBear.py: Add pyre-check bear #2689

Closed
wants to merge 1 commit into from
Closed

PyreBear.py: Add pyre-check bear #2689

wants to merge 1 commit into from

Conversation

atb00ker
Copy link

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

  • I read the commit guidelines and I've followed
    them.
  • I ran coala over my code locally. (All commits have to pass
    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:

The more you review, the more your score will grow at coala.io and we will
review your PRs faster!

@atb00ker
Copy link
Author

atb00ker commented Sep 10, 2018

The tests continuous-integration/appveyor/pr & continuous-integration/travis-ci/pr run on Python-3.4, pyre-check is available for Python 3.5+; Hence the test failed.

@atb00ker atb00ker changed the title PyreBear.py: Add pyre-check bear [WIP] PyreBear.py: Add pyre-check bear Sep 10, 2018
@atb00ker
Copy link
Author

atb00ker commented Sep 10, 2018

Hi! @li-boxuan
Thanks, made changes as per suggestions! 😄

@gitmate-bot
Copy link
Collaborator

Sorry @atb00ker, you do not have the necessary permission levels to perform the action.

@atb00ker atb00ker changed the title [WIP] PyreBear.py: Add pyre-check bear PyreBear.py: Add pyre-check bear Sep 10, 2018
@atb00ker
Copy link
Author

Python 3.5.6 fail looks like it's because of an issue with pyre-check
For more, please follow: facebook/pyre-check#102

@atb00ker
Copy link
Author

travis-ci and appveyor are failing because pyre-check only supports Python >= 3.5

# Check Result Lines & Columns
lines = [result.affected_code[0] for result in results]
# For Message #1
self.assertEqual(lines[0].end.column, 4)
Copy link
Member

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?

Copy link
Author

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

Copy link
Member

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 😉

Copy link
Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

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. 👍

@atb00ker
Copy link
Author

atb00ker commented Jan 26, 2019

@li-boxuan updated! 😄
Please let me know your views! 😄

@jayvdb
Copy link
Member

jayvdb commented Feb 4, 2019

@gitmate-bot rebase

@gitmate-bot
Copy link
Collaborator

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 ⚠️

@gitmate-bot
Copy link
Collaborator

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')}
Copy link
Member

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

Copy link
Author

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
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.

Bear Proposal: pyre
4 participants