Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm code style check via command line

Tags:

python

pycharm

Is it possible to run the PyCharm linter / code style checks from command line and get the warnings/errors?

Extension to that: Is it possible to integrate that in my Travis tests?

like image 758
Albert Avatar asked Sep 14 '26 08:09

Albert


1 Answers

To put some of the comments and some further research into an answer:

PyCharm comes with a small command-line utility bin/inspect.sh, which is documented here. This tool is quite limited though, and has some problems, e.g. it cannot run while the PyCharm IDE is running, and it reports somewhat incorrectly / different than the IDE. Related code can be seen e.g. here. PyCharm does not do PEP8 code style checks by itself but uses the (bundled) pycodestyle tool.

Maybe these shortcomings can be fixed upstream. See e.g. this report, or this, or this.

I'm using this in Travis and GitHub Actions now, via this script. This also does the necessary setup of a project. This also compensates for the inspect.sh missing warnings by also using the pycodestyle tool and thus exactly matching the PyCharm IDE warnings.

Alternative, I'm thinking about writing an extended simple utility which basically does this. All the relevant PyCharm code is open source. I created a project page pychar-inspect for this. But this is just in the planing phase currently, and maybe obsolete when this will be addressed upstream.

like image 91
Albert Avatar answered Sep 16 '26 22:09

Albert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!