Skip to content

Commit

Permalink
Linting with Ruff (#2033)
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyheppell committed Jun 19, 2024
1 parent 0a28916 commit 70d7725
Show file tree
Hide file tree
Showing 76 changed files with 4,372 additions and 2,659 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[test]"
- name: Ruff Format Check
run: ruff format --check .
id: format
- name: Ruff Lint Check
run: ruff check --output-format=github .
# Still run if format check fails
if: success() || steps.format.conclusion == 'failure'
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ If you are using conda, you can approach it as follows:

❗Note: Unit testing the package can take quite some time since it needs to run several variants of the BERTopic pipeline.

## 🧹 Linting and Formatting

We use [Ruff](https://docs.astral.sh/ruff/) to ensure code is uniformly formatted and to avoid common mistakes and bad practices.

* To automatically re-format code, run `make format`
* To check for linting issues, run `make lint` - some issues may be automatically fixed, some will not be

When a pull request is made, the CI will automatically check for linting and formatting issues. However, it will not automatically apply any fixes, so it is easiest to run locally.

If you believe an error is incorrectly flagged, use a [`# noqa:` comment to suppress](https://docs.astral.sh/ruff/linter/#error-suppression), but this is discouraged unless strictly necessary.

## 🤓 Collaborative Efforts

When you run into any issue with the above or need help to start with a pull request, feel free to reach out in the issues! As with all repositories, this one has its particularities as a result of the maintainer's view. Each repository is quite different and so will their processes.
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ test:
coverage:
pytest --cov

format:
ruff format

lint:
ruff check --fix

install:
python -m pip install -e .

Expand Down
Loading

0 comments on commit 70d7725

Please sign in to comment.