@@ -101,10 +101,43 @@ echo
101101# Print out the commands being run
102102set -x
103103
104+ # Ensure the sort order of imports.
104105isort " ${files[@]} "
106+
107+ # Ensure Python code conforms to an opinionated style.
105108python3 -m black " ${files[@]} "
109+
110+ # Ensure the sample configuration file conforms to style checks.
106111./scripts-dev/config-lint.sh
112+
113+ # Catch any common programming mistakes in Python code.
107114# --quiet suppresses the update check.
108115ruff --quiet " ${files[@]} "
116+
117+ # Catch any common programming mistakes in Rust code.
118+ #
119+ # --bins, --examples, --lib, --tests combined explicitly disable checking
120+ # the benchmarks, which can fail due to `#![feature]` macros not being
121+ # allowed on the stable rust toolchain (rustc error E0554).
122+ #
123+ # --allow-staged and --allow-dirty suppress clippy raising errors
124+ # for uncommitted files. Only needed when using --fix.
125+ #
126+ # -D warnings disables the "warnings" lint.
127+ #
128+ # Using --fix has a tendency to cause subsequent runs of clippy to recompile
129+ # rust code, which can slow down this script. Thus we run clippy without --fix
130+ # first which is quick, and then re-run it with --fix if an error was found.
131+ if ! cargo-clippy --bins --examples --lib --tests -- -D warnings > /dev/null 2>&1 ; then
132+ cargo-clippy \
133+ --bins --examples --lib --tests --allow-staged --allow-dirty --fix -- -D warnings
134+ fi
135+
136+ # Ensure the formatting of Rust code.
137+ cargo-fmt
138+
139+ # Ensure all Pydantic models use strict types.
109140./scripts-dev/check_pydantic_models.py lint
141+
142+ # Ensure type hints are correct.
110143mypy
0 commit comments