Thank you for both for good solutions. At the moment I’m fine with flake8 ending execution of my script.
I was a bit stumped by the fact that my sys.argv variable is used by flake8.main(). After reading your answer I realized that I can easily modify sys.argv to simulate a cli call. Since asking the question I found an alternative called prospector. Anyone have any thoughts about that project? To me (quite the novice) it looks like a promising alternative. Linus Törngren > 22 okt. 2015 kl. 17:04 skrev Ian Cordasco <graffatcolmin...@gmail.com>: > > On Thu, Oct 22, 2015 at 9:08 AM, Peter Bittner <peter.bitt...@gmx.net> wrote: >> Maybe like this? >> >> ``` >> from flake8.main import main >> >> main() >> ``` > > This is easily the most correct way of doing it. > > Notice that it's not exactly a public API and we do not return > anything. You'll have to wrap it in > > ``` > from flake8 import main as flake8 > > try: > flake8.main() > except SystemExit: > # Whatever handling you want > ``` > > If you do not want flake8 to quit your script for you.
_______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality