17

Is there already a way to integrate one of Python lint programs (PyLint, PyChecker, PyFlakes, etc.) with GitHub commit status API? In this way Python lint could be automatically called on pull requests to check the code and provide feedback and code (and style).

Alexey Kachayev
  • 6,106
  • 27
  • 24
Mitar
  • 6,756
  • 5
  • 54
  • 86
  • possible duplicate of [Enforcing PEP-8'ish formatting in Github commits](http://stackoverflow.com/questions/9799209/enforcing-pep-8ish-formatting-in-github-commits) – Martijn Pieters Sep 16 '12 at 20:14
  • Presumably, that's exactly the sort of thing it's for. Is that your question? – Hamish Sep 16 '12 at 20:14
  • 3
    @MartijnPieters this is nothing to do with commit hooks. – Hamish Sep 16 '12 at 20:14
  • So I understand that Python lint programs can in theory be integrated with GitHub commit status API. My questions is if there is already something like this available somewhere? Or as an existing cloud services or as an installation I can put on my server and it is called from GitHub. – Mitar Sep 16 '12 at 22:30

2 Answers2

8

You could use something like Travis-CI, and run pylint as part of your tests, along the lines of:

language: python
install: "pip install nose pylint"
script: "nosetests && pylint"

Of course that fails commits for minor stylistic violations - you'd probably want to disable certain messages, or use pylint --errors-only to make it less stringent

dbr
  • 165,801
  • 69
  • 278
  • 343
  • Hm, there is [ticket](https://github.com/travis-ci/travis-ci/issues/451) which says this is not yet supported? Probably there should be difference between error and warning here? – Mitar Sep 18 '12 at 05:49
  • 1
    @Mitar yep - what's missing is any nice presentation of the pylint output (like "tests passed, but linter failed), or ability to store the HTML-report output along with the build. So it'd work, but rather crudely – dbr Sep 18 '12 at 18:37
  • @dbr the app in my answer purports to store the HTML report and provides a nice SVG badge for use as a README status image. – Stew Feb 20 '16 at 22:16
  • Travis might be too much for simple linting. As the suggested app is now way out of date, I suggest using [a small golang app](https://github.com/PatWie/pylint/) which features the new GitHub Checks API. But this must be self-hosted somewhere. – Patwie Aug 03 '18 at 21:01
2

I had the same question, and just found this blog post describing a project called pylint-server for doing something similar (though triggered on Travis CI build events, not pulls).

From the README:

A small Flask app to keep keep track of pylint reports and ratings on a per-repository basis.

I haven't tried it yet, so I can't comment on its quality. If anyone tries it, please comment and let us know how you like it.

Stew
  • 4,495
  • 6
  • 31
  • 41