I am using Pylint on a project and would like to use it as a step of our continuos integration, where the build should fail fast if Pylint outputs any messages. I have looked in the documentation, but have been unable to find any solution, but to run the linting to completion before it returns an error status. Is it possible to fail fast with Pylint?
Asked
Active
Viewed 186 times
0
-
1You are trying to built a developer frustration factory? A pipeline tool should give a proper and complete output of its task and not force the developer to fix every problem one by one. I don't even consider a linter message a reason to fail the pipeline. – Klaus D. Jul 14 '21 at 08:10
-
you can take the score of lint to proceed for the next step in your CI Process https://stackoverflow.com/a/39454034/10849457 – Vignesh Jul 14 '21 at 08:12
-
How much code do you have? In most cases lint is pretty fast already, and it has the `-j` option to run in parallel. This doesn't seem like an obvious step to optimise, particularly with the trade-off as pointed out by @klaus-d? – Jiří Baum Jul 14 '21 at 08:17
-
@KlausD. Haha. We have turned most of Pylint off since it contains so much noise and have written some checkers that inspect for some critical errors in our project, which should fail the pipeline before being released. The reason it should fail fast and not show all messages, is that it takes quite some time on the whole project and we would like to indicate as fast as possible that something is wrong. – Alexander Kvist Jul 14 '21 at 08:18
-
@sabik Over 600 Python files or ~250.000 lines of code. It takes approximately 150 seconds to run the linter to completion. – Alexander Kvist Jul 14 '21 at 08:21
-
The purpose of a pipeline is to take time consuming jobs away from the developers. And frankly 150s is nothing. I thought we where talking about something like 30 min. – Klaus D. Jul 14 '21 at 08:28
-
You might be right, maybe it's not worth pursuing. For me 150 seconds feels like a lot though, since our build usually only takes 8 minutes. – Alexander Kvist Jul 14 '21 at 08:39
-
1Can you run it in parallel? Probably a lot easier than trying to optimise it... – Jiří Baum Jul 14 '21 at 09:09
-
1In principle, you could watch the output of `pylint` and abort as soon as it prints out anything; in practice, this is complicated by the fact that once output is redirected, it'll implicitly be block-buffered, so you'd have to muck around with tty/pty to turn the buffering off again. – Jiří Baum Jul 14 '21 at 09:17
-
@sabik It's already running with j=4, so not much more to do there. You might be on to something there, I could run it as a separate process and just kill it when it produces anything. It's not pretty, but it would work. – Alexander Kvist Jul 14 '21 at 09:29
-
2You could also run it in parallel with the rest of the build, which would give you 8 minutes... – Jiří Baum Jul 14 '21 at 09:33
-
BTW, depending on the number of cores, j can go much higher, particularly if it's running in a context where the cores are sitting there anyway – Jiří Baum Jul 14 '21 at 09:35