diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index c2f7e71fc..a49c7c8d0 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -9,6 +9,10 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: + - id: changed-files + uses: tj-actions/changed-files@v47 - uses: actions/checkout@v3 - uses: actions/setup-python@v3 - uses: pre-commit/action@v3.0.0 + with: + extra_args: --files ${{ steps.changed-files.outputs.all_changed_files }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 30a90c04f..31f242ca6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,3 @@ -files: _shared_utils repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 @@ -12,7 +11,7 @@ repos: rev: 7.3.0 hooks: - id: flake8 - args: ["--ignore=E501,W503,F403,F405,E711,E712,E231,E702,E203"] + args: ["--ignore=E501,W503,F403,F405,E711,E712,E231,E702,E203"] # E711: comparison to None should be 'if cond is not None:' (siuba filtering requires we use != None and not is not) # E712: line too long and line before binary operator (black is ok with these), assign lambda expression OK, comparison to True with is (siuba uses ==) # E231: missing whitespace after colon (we don't want white space when setting gs://) diff --git a/README.md b/README.md index 346d01dff..42ef0e38c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # data-analyses Place for sharing quick reports, and works in progress -This repository is for quick sharing of works in progress and simple analyses. +This repository is for quick sharing of works in progress and simple analyses. For collaborative short-term tasks, create a new folder and work off a separate branch. For longer-term projects, consider making a new repository! @@ -9,6 +9,19 @@ For longer-term projects, consider making a new repository! * Use [this link](https://docs.calitp.org/data-infra/analytics_tools/saving_code.html#onboarding-setup) to get started in JupyterHub, set up SSH, and start commiting to the repo! +### Contributing +#### Pre-commit + +This repository uses pre-commit hooks to format code, including [Black](https://black.readthedocs.io/en/stable/index.html). This ensures baseline consistency in code formatting. + +> [!IMPORTANT] +> Before contributing to this project, please install pre-commit locally by running `pip install pre-commit` and `pre-commit install` in the root of the repo. + +Once installed, pre-commit checks will run before you can make commits locally. If a pre-commit check fails, it will need to be addressed before you can make your commit. Many formatting issues are fixed automatically within the pre-commit actions, so check the changes made by pre-commit on failure -- they may have automatically addressed the issues that caused the failure, in which case you can simply re-add the files, re-attempt the commit, and the checks will then succeed. + +Installing pre-commit locally saves time dealing with formatting issues on pull requests. There is a [GitHub Action](./.github/workflows/lint.yml) +that runs pre-commit on all files, not just changed ones, as part of our continuous integration. + ## Quick Links - Get Started in Data Analysis #### Data Analytics Documentation - Welcome