Skip to content

Commit

Permalink
replace black with ruff format; upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dlstadther committed Nov 3, 2023
1 parent 3c0910d commit 8b2626d
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 238 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
curl -sSL https://install.python-poetry.org | python3 - --version 1.6.1
poetry install
- name: Format checking with Black
run: poetry run black --check .
- name: Format checking with Ruff Format
run: poetry run ruff format --check .

lint:
runs-on: ubuntu-latest
Expand Down
12 changes: 3 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,11 @@ repos:
- id: end-of-file-fixer # Makes sure files end in a newline and only a newline
- id: trailing-whitespace # Trims trailing whitespace

# black
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black

# ruff
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: v0.0.259
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: ruff-format
- id: ruff

# mypy
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ poetry run pre-commit run

# To run a particular pre-commit hook against staged files before committing:
# poetry run pre-commit run <hook>
poetry run pre-commit run black
poetry run pre-commit run ruff-format
poetry run pre-commit run ruff
poetry run pre-commit run mypy

# To run a particular pre-commit hook against all files (staged and unstaged, before committing):
poetry run pre-commit run ruff --all-files

# run checks regardless of git status
poetry run black --check src
poetry run ruff format --check src
poetry run mypy src
poetry run ruff src
```
Expand Down Expand Up @@ -95,13 +95,13 @@ Pre-Commit hooks run during `git commit ...` in order to apply checks for qualit

The checks contained in this repo include (in the order in which they run):
* Various checkers and formatters to verify valid file types, file size, and end of line and end of file whitespace/newlines
* The `black` formatter will apply a standard code style format
* `ruff format` applies standard code style formatting (just like `black`, but faster)
* `ruff` checks code for "lint"
* `mypy` is used for static type checking
* `poetry` checks on valid and aligned pyproject.toml and poetry.lock files
* `sqlfluff` checks and fixes sql formatting and linting

If you want `black` to ignore a particular section of code, you can add the comments `# fmt: off` and `# fmt: on` before and after the respective block of code.
If you want `ruff format` to ignore a particular section of code, you can add the comments `# fmt: off` and `# fmt: on` before and after the respective block of code (same as you would if using `black`).
* https://stackoverflow.com/a/58584557

If you want `mypy` to ignore a particular line of code, you can add the comment `# type: ignore` to the end of that line.
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def tests(session: nox.Session) -> None:
@nox.session
def lint(session: nox.Session) -> None:
session = _install_poetry(session=session)
session.run("black", "--check", ".")
session.run("ruff", "format", "--check", ".")
session.run("ruff", "--output-format=github", ".")
session.run("sqlfluff", "lint", ".")

Expand Down
Loading

0 comments on commit 8b2626d

Please sign in to comment.