Last modified: 2026-11-14 03:52:56 (PST)
The lab’s Python style is an amendment of Google’s Python style guide, read in the lab’s fork at a pinned commit. Follow that guide for everything the amendments below do not change. Google’s current wording is at google.github.io/styleguide/pyguide.html.
Ruff replaces the pylint configuration and the Pyink formatter that Google’s guide mentions. It lints and formats in one tool.
python/ruff.toml in the Morrison-Lab/psc repository. Copy it to the root of a repository as ruff.toml.CI runs the checks and fails on any finding.
The lab’s no-nested-calls rule applies to Python. Give each intermediate result a name. Method chaining is fine. Ruff cannot check this rule, so it is not yet enforced.
Draw 2-D figures with plotnine, a Python implementation of the grammar of graphics. Its calls mirror the lab’s ggplot2 code, so a figure reads the same in R and in Python, and the lab’s qnp theme carries over. Draw 3-D figures with plotly, because plotnine draws no 3-D graphics. Do not use Matplotlib directly for figures in new code. Name every argument, including those inside aes(), as the name-arguments rule says for R. Convert existing Matplotlib figures in their own PRs, not in unrelated ones.
Morrison-Lab/gha’s check-python-package workflow in every repository that contains Python.check-python-qmd-chunks in every repository whose .qmd files contain Python chunks.These are tracked in #90.