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

Add flake8 checks #2363

Merged
merged 10 commits into from
Feb 22, 2017
Merged

Add flake8 checks #2363

merged 10 commits into from
Feb 22, 2017

Conversation

punchagan
Copy link
Contributor

@punchagan punchagan commented Sep 16, 2016

  • The checks will run automatically on Travis.
  • Getting a 100% coverage will require significantly more effort and
    work, but having flake8 checks can give us some of the benefits for a
    relatively low cost. Issues like Add missing import for _ in rest/viewsets.py #2361 can easily be avoided.

Test plan

  • All the tests should pass (but our coverage isn't all the way there)
  • Some basic manual testing?

This is a fairly big change, but most of the changes were made automatically using autopep8 and autoflake. Each commit tries to stick to one kind of fix, to help review.

Closes #2477

Copy link
Contributor

@zzgvh zzgvh left a comment

Choose a reason for hiding this comment

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

I like this in general. I'm using PyCharm so I get some of PEP8 for free, but definitely not all.

One personal issue is that I don't like the 79 char line length limit 😉, I prefer 100 chars. Sure I can adjust, but there's a lot of code that's up to 100 chars wide...

For some reason Travis isn't happy running this right now.

@punchagan punchagan force-pushed the add-flake8-checks branch 2 times, most recently from bc8e7e7 to ee58a8c Compare September 19, 2016 05:58
@punchagan
Copy link
Contributor Author

I like this in general. I'm using PyCharm so I get some of PEP8 for free, but definitely not all.

Sure. I have some checks in my editor too, and that's how I found #2361. But, I think it is good to have some checks before merging/deploying to avoid trivial bugs.

One personal issue is that I don't like the 79 char line length limit , I prefer 100 chars. Sure I can adjust, but there's a lot of code that's up to 100 chars wide...

I am not very fond of this limit either. I've actually disabled this check, when running it on travis (E501). Sorry for not mentioning this in the PR description.

For some reason Travis isn't happy running this right now.

There was a missing import which was fixed in #2361 and Travis is now happy.

@zzgvh
Copy link
Contributor

zzgvh commented Sep 19, 2016

Great! So how do we merge this? Ideally we shouldn't have any other outstanding PRs when this is merged as there's a good chance these changes will introduce conflicts.

@punchagan
Copy link
Contributor Author

All the pending PRs are small, except for the DRF update PR. We can either wait for them to be merged, or just go ahead with merging this one, because the conflicts will be pretty small, if any.

For the DRF update PR: If you think that would be merged in reasonably soon, this can wait for that PR to be in. Otherwise, I can help rebase that PR onto the new develop branch, after this has been merged.

@zzgvh
Copy link
Contributor

zzgvh commented Sep 19, 2016

Yep, you're right. We might as well merge this then.

I have researched one of the larger fixes needed in the DRF update branch, it's the endpoint pagination. What's needed there is mostly code removal and some config since DRF 3 includes much better pagination tools, so the custom hack Kasper wrote after the DRF update branch was made can be thrown away in large part.

So if you think you can fix the style related changes in that branch it'd be great and shouldn't make things harder on my end.

@punchagan
Copy link
Contributor Author

Let's merge it then! 👍

So if you think you can fix the style related changes in that branch it'd be great and shouldn't make things harder on my end.

I can help with this, once that branch is ready for a review. Or whenever you think, this should be done.

@punchagan
Copy link
Contributor Author

Commits need reference to an issue number

@punchagan punchagan modified the milestone: 3.20 Bogotá Nov 29, 2016
@punchagan
Copy link
Contributor Author

This should now be merge-able, @zzgvh. (after #2476 is merged)

Used the autoflake tool and ran the following command:

    find akvo/ -name "*.py" |grep -v __init__.py|grep -v migration|xargs autoflake -i -r --remove-all-unused-imports
Ran the following command and made some minor manual edits:

    find akvo/ -name "*.py" |grep -v __init__.py|grep -v migration|xargs autoflake -i -r --remove-unused-variables
    find akvo/ -name "*.py" |grep -v __init__.py|grep -v migration|xargs \
    autopep8 -i --select E231,E203,E225,E226,W291,E228,E201,E202,W293,E302,E301,W391
    find akvo/ -name "*.py" |grep -v __init__.py|grep -v migration|xargs \
    autopep8 -i --select \
    E221,E241,E251,E271,E272,E115,E122,E123,E124,E125,E126,E127,E128,E231,E203,E225,E226,W291,E228,E201,E202,W293
    find akvo/ -name "*.py" |grep -v __init__.py|grep -v migration|xargs autopep8 -i --select E261,E265,E266,E221,E241,E251,E271,E272,E401,E402,E403,E405
    find akvo/scripts/ -name "*.py"|xargs autopep8 -i --ignore E501
- The checks will run automatically on Travis.

- Getting a 100% coverage will require significantly more effort and
  work, but having flake8 checks can give us some of the benefits for a
  relatively low cost.  Issues like #2361 can easily be avoided.
@punchagan punchagan merged commit 0338b9a into develop Feb 22, 2017
@punchagan punchagan deleted the add-flake8-checks branch February 22, 2017 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Replace Landscape code quality tests with flake8 and/or pylint
2 participants