Linting

Our developers come from a wide variety of professional backgrounds, and we do not expect them to be Python experts. One tool the Caliper SDK provides to promote code quality and provide education on Python best practices is linting.

The SDK comes with a package called “ruff” which will check code for style and structure in accordance with standards agreed upon by the Python community. This is the same tool that the Caliper team uses to maintain clean code in the product itself.

To run linting on your extensions, run q2 lint at the command line.

Don’t be discouraged if you get a lot of errors. They are all generally simple to fix and the styles will become automatic as you gain experience with Python. Readable code and friendly syntax are major features of the language, and linting will help you best leverage them.

We do not require linting to be performed on submitted code, but it will greatly expedite the review process and help us catch errors or inefficiencies if any exist.

You may find some of the Ruff rules excessively burdensome or just not useful: that’s okay too. Your extension has its own pyproject.toml file that can be changed to meet your needs. This is a shared file that can be used to configure many parts of the python ecosystem. For information on how to make changes to your personal linting rules see the Ruff documentation.