terrier-org / pyterrier

A Python framework for performing information retrieval experiments, building on http://terrier.org/
https://pyterrier.readthedocs.io/
Mozilla Public License 2.0
415 stars 65 forks source link

static analysis tools #482

Open seanmacavaney opened 1 month ago

seanmacavaney commented 1 month ago

Let's add static analysis tools, like flake8/mypy/ruff/etc into the automatic build.

The questions are:

Maybe we also want to make sure that the docs also build without errors (in QUICK=1 mode) as another check?

Context: We currently test a few custom rules using a flake8 extension: extras/pyterrier-flake8-ext config is here: https://github.com/terrier-org/pyterrier/blob/master/.github/workflows/style.yml

It looks like we used flake8 previously, but it was commented out? https://github.com/terrier-org/pyterrier/blob/master/.github/workflows/push.yml#L73C13-L79

I've been using ruff with this config in a few extension packages

cmacdonald commented 1 month ago

It looks like we used flake8 previously, but it was commented out? https://github.com/terrier-org/pyterrier/blob/master/.github/workflows/push.yml#L73C13-L79

It was never used really. I think it was copied over from another project's yml file.

One thing with flake, mypy etc is how to detect /changes/ - i.e. more errors than the baseline. Simplest thing I can think of is somehow storing the most recent mypy output in .github folder, and doing a diff? We'd have to work out how to see if the error count was reduced though

seanmacavaney commented 1 month ago

One thing with flake, mypy etc is how to detect /changes/ -

I think I disagree here -- we find a set of rules that need to be adhered to throughout the codebase. Then there's no notion of a delta, since it should always be 0 errors. (# noqa can be used in cases of exceptions to the rule.)

It's akin to our unit tests -- we don't have unit tests that we accept are failing and measure a delta between new failures and old failures :-)