-
Notifications
You must be signed in to change notification settings - Fork 110
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 pylint checks to Travis #147
Comments
There are a few checks pylint enforces that may be preferable to turn off. Spaces around operators, for example. Sometimes it's more readable for sympy code not to enforce |
Sure, we can do that. But I'm also of the opinion that being nit picky about this doesn't gain much. In general, the pep 8 stuff is a good choice, and makes code consistent. To me it is worth having some of the oddities that pep 8 enforces in place just to stick with the whole standard instead of pieces of it. Since sympy grew organically, now everyone wants their particular preferences when it comes to pep8 and it is virtually impossible to introduce enforced linting at all. I doubt it ever will happen. It's much easier to say: "PyDy source code follows the PEP8." than "PyDy source code follows PEP8 except for ...., ..., ....". We are early enough in development that we can make the first proclamation without too many obstructions. |
Sure, and I agree that for the most part the ones I've listed should be followed. But sometimes I feel that 100% enforcement of those 3 can read to less readable code. The operators rule is great for only a few operations, but for long mathy expressions can make line length longer, and the grouping of operations is harder to follow (IMO). The indentation one also can be a pain. For example:
is a lot more readable than doing the mandated 2 indent levels:
SymPy uses some magic that makes enforcing other ones hard. For example, some of the code needs to distinguish between I'm not opposed to enforcing code quality, but some rules should allow exceptions when the code would be more readable without them. |
I agree that some of PEP 8's rules aren't ideal. But I think we can come up with many more things that we don't like and if everyone chimes in, each person will have a different set of complaints about PEP8. I'm simply for choosing a standard and dealing with the oddities as opposed to creating our own standard to maintain. If you can list the exact things to turn off in the linters, then we can implement that as "our standard". BTW, my linting setup (standard install) does not complain about your first matrix example. I've never seen an error about standard 2 indents. I think brace alignment is valid. Also note that PEP8 does not suggest spaces around all operators: https://www.python.org/dev/peps/pep-0008/#other-recommendations I also don't like the spacing between functions rule either. It isn't good for all cases. But I just do it because the linter doesn't complain. It's not that big of deal. |
I suppose my experience has been with flake8 (which does complain about those things), not pylint. If the examples I gave don't error out, then that's fine. |
Interesting, I wonder why all the linters are not the same. |
I can also see how enforcing linting on Travis will create problems when people don't have the same linter installed or don't have the same settings. This could just create a headache. Maybe we just need the "please lint your code" in the checklist idea and be happy if everyone runs some version of linting locally. |
We could just do very limited linting, and recommend people to lint their code locally. Things that should mandatory:
|
http://stackoverflow.com/questions/1428872/pylint-pychecker-or-pyflakes Maybe we just want the PEP8 checker and none of the other linting. |
I like a simplified linting idea for Travis. |
I never realized there are so many different flavors of linting for Python...aaaah!! |
Hi, is this issue suited for a GSoC patch? |
This issue has not been fixed. We'd like to pick one of the linters, probably just pep8 because I don't think we want to enforce other things. Note Jim's list of the basics that we'd like to check. This PR will also involve fixing those errors in the existing code to get the checks to pass. |
Yes, this will suite for a GSoC patch. |
Ok, thanks. Which list do you mean, everything of PEP8 without the 3 things Jim mentioned above? |
Should the Travis build fail when |
I think we want to check a minimum of things. Start with Jim's list of 3 or 4 items. I think we want Travis to fail for just those 3 or 4 items. It should have a message to the user that says, "please run a linter and fix errors, e.g. pylint, flake8, pep8, etc". This will encourage people to run more linters locally than we run on Travis. All of the Python code in I think we should check the examples too. |
Great, thanks. Sorry, I read over Jim's list three times. This list should be doable for all directories. |
PyDy current only supports Python 2. So please use the 2.7 linter for now. |
pep8 doesn't seem to warn about I recommend looking at pyflakes first (it only checks actual logical errors, like undefined variables). You can use |
Thanks for the tips @asmeurer. I think our goal here should be to check some minimum set of things on Travis. If Travis checks some basic errors, then it will encourage people to run some kind of linter locally, in which case they'll probably clean up their code further than what Travis suggests. So instead of this being a hardline to cross to get code submitted, it just nudges people in the right direction. |
Thank you both for your comments. |
Ok, I created a pull request, please have a look at it. |
Do you know what the |
Haha, yes that's a temporary directory created during the code generation tests. |
Ok, apparently the temporarily generated code is not PEP 8 compliant. :) |
The rename sounds fine. It is actually purposely not pep8 compliant to make the code generation easier and cleaner. |
Can you have travis remove the |
Or ignore it? |
Is it ok to delete |
Sorry for having that many false positives, these were all found by |
Should I add new comments, partially reverting the previous ones, or make a new branch? |
I think so, but I'd have to look closer.
I think it is better to exclude than include because we'll never remember to include things that we add in the future. |
Just work on this same branch and keep pushing commits to it. The PR will update accordingly. |
Ok, thanks. I just noticed I skipped over the |
Another thought on this is to just use a service like: https://landscape.io/ I've never tried it or know if it costs anything. |
Ok, landscape.io looks like a good general option for code checking, maybe more semantically than syntactically, compared to linters. |
Added basic PEP 8 to .travis.yml and fixed currently reported issues. Fixes #147.
Thanks for merging. I am currently trying out https://landscape.io/, but the check seems to time out after 30 minutes. Apparently this service is relatively new, so maybe they will fix this soon. BTW, how did you make those checkboxes and the |
Task lists are supported by Github: https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments See here for our standard check lists for PRs: https://github.com/pydy/pydy/blob/master/CONTRIBUTING.rst |
Great, thanks! |
We should lint all the Python code with the latest PEP8 at least. I don't see any reason not to follow PEP8 guidelines.
The text was updated successfully, but these errors were encountered: