Skip to content

Commit

Permalink
Upgrade Ruff and remove Black linter
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer committed Aug 20, 2024
1 parent 75ce9d0 commit d76f8f7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
11 changes: 4 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:
# See https://pre-commit.com/hooks.html for info on hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -20,12 +20,9 @@ repos:
- id: forbid-new-submodules
- id: trailing-whitespace

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

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
rev: v0.6.1
hooks:
- id: ruff
- id: ruff-format
args: ["--check"]
2 changes: 1 addition & 1 deletion pelican/plugins/minify/minify.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def write_to_file(path_file, callback):
f.seek(0)
f.write(content)
f.truncate()
except Exception as e: # NOQA: BLE001
except Exception as e:
raise Exception( # NOQA: TRY002, TRY003
f"Unable to minify file {path_file}. Exception was: {e!r}"
) from e
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ markdown = ["markdown>=3.4"]

[tool.pdm.dev-dependencies]
lint = [
"black>=23.7.0",
"invoke>=2.2.0",
"ruff>=0.1.8",
"invoke>=2.2",
"ruff>=0.6.0,<0.7.0",
]
test = [
"markdown>=3.4",
"pytest>=7.0",
"pytest-cov>=4.0",
"pytest-sugar>=0.9.7",
"pytest-sugar>=1.0",
]

[tool.pdm.build]
Expand All @@ -80,7 +79,7 @@ git-username = "botpub"
git-email = "[email protected]"
append-github-contributor = true

[tool.ruff]
[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"BLE", # flake8-blind-except
Expand Down Expand Up @@ -111,9 +110,10 @@ ignore = [
"D104", # missing docstring in public package
"D203", # blank line before class docstring
"D213", # multi-line docstring summary should start at the second line
"ISC001", # disabled so `ruff format` works without warning
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
combine-as-imports = true
force-sort-within-sections = true
known-first-party = ["pelican"]
Expand Down
10 changes: 6 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ def tests(c, deprecations=False):


@task
def black(c, check=False, diff=False):
"""Run Black auto-formatter, optionally with `--check` or `--diff`."""
def format(c, check=False, diff=False):
"""Run Ruff's auto-formatter, optionally with `--check` or `--diff`."""
check_flag, diff_flag = "", ""
if check:
check_flag = "--check"
if diff:
diff_flag = "--diff"
c.run(f"{CMD_PREFIX}black {check_flag} {diff_flag} {PKG_PATH} tasks.py", pty=PTY)
c.run(
f"{CMD_PREFIX}ruff format {check_flag} {diff_flag} {PKG_PATH} tasks.py", pty=PTY
)


@task
Expand All @@ -58,7 +60,7 @@ def ruff(c, fix=False, diff=False):
def lint(c, fix=False, diff=False):
"""Check code style via linting tools."""
ruff(c, fix=fix, diff=diff)
black(c, check=(not fix), diff=diff)
format(c, check=(not fix), diff=diff)


@task
Expand Down

0 comments on commit d76f8f7

Please sign in to comment.