Skip to content

Commit

Permalink
fix: Black wouldn't run if Ruff failed
Browse files Browse the repository at this point in the history
  • Loading branch information
MicaelJarniac committed Jul 6, 2023
1 parent 3f833b4 commit 39309b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
21 changes: 7 additions & 14 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,16 @@ def pre_commit(session: nox.Session) -> None:

@nox.session(python=python_versions[-1], venv_params=venv_params)
def lint_files(session: nox.Session) -> None:
"""Lint and fix files.
Pass `--check` to only lint, not fix.
`nox -s lint_files -- --check`
"""
"""Lint and fix files."""
install(session, groups=["linting"], root=False)
session.run("ruff", "check", ".", "--fix")

command_ruff = ["ruff", "check", "."]
command_black = ["black", "."]

if "--check" in session.posargs:
command_black.append("--check")
else:
command_ruff.append("--fix")

session.run(*command_ruff)
session.run(*command_black)
@nox.session(python=python_versions[-1], venv_params=venv_params)
def format_files(session: nox.Session) -> None:
"""Format files."""
install(session, groups=["formatting"], root=False)
session.run("black", ".")


@nox.session(python=python_versions, venv_params=venv_params)
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ nox = "^2023.4.22"
pytest = "^7.4.0"

[tool.poetry.group.linting.dependencies]
black = "^23.3.0"
ruff = "^0.0.275"

[tool.poetry.group.formatting.dependencies]
black = "^23.3.0"

[tool.poetry.group.pre-commit.dependencies]
pre-commit = "^3.3.3"

Expand Down

0 comments on commit 39309b5

Please sign in to comment.