Skip to content

Commit

Permalink
Exclude the vendor directory from linting
Browse files Browse the repository at this point in the history
(also lint with ruff :D )
  • Loading branch information
offbyone committed Oct 31, 2024
1 parent 66be838 commit 06970fe
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 242 deletions.
20 changes: 7 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ git-username = "botpub"
git-email = "[email protected]"
append-github-contributor = true

[tool.isort]
# Maintain compatibility with Black
profile = "black"
multi_line_output = 3
[tool.ruff]
exclude = ["pelican/plugins/webassets/vendor/"]

# Sort imports within their section independent of the import type
force_sort_within_sections = true
[tool.ruff.lint.isort]
section-order = ["future", "standard-library", "first-party", "pelican", "local-folder", "third-party"]

# Designate "pelican" as separate import section
known_pelican = "pelican"
sections = "FUTURE,STDLIB,THIRDPARTY,PELICAN,FIRSTPARTY,LOCALFOLDER"
[tool.ruff.lint.isort.sections]
pelican = ["pelican"]

[build-system]
requires = ["hatchling", "hatch-vcs", "hatch-fancy-pypi-readme>=22.8.0"]
Expand Down Expand Up @@ -68,17 +66,13 @@ dependencies = [
dev = [
"cssmin == 0.2.0",
"libsass >=0.22.0",
"black == 23.3.0",
"flake8 == 3.9.2",
"flake8-black == 0.3.6",
"invoke == 2.2.0",
"isort == 5.11.5",
"markdown == 3.4.4",
"pytest == 6.2.5",
"pytest-cov == 3.0.0",
"pytest-sugar == 0.9.7",
"ruff>=0.7.1",
]

markdown = [
"markdown == 3.4.4",
]
39 changes: 10 additions & 29 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from inspect import cleandoc
import os
import sys
from inspect import cleandoc
from pathlib import Path
from shutil import which
import sys

from invoke import task

Expand All @@ -29,39 +29,20 @@ def tests(c):


@task
def black(c, check=False, diff=False):
"""Run Black 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")


@task
def isort(c, check=False, diff=False):
"""Ensure imports are sorted according to project standards."""
check_flag, diff_flag = "", ""
if check:
check_flag = "-c"
def ruff(c, fix=False, diff=False):
"""Run Ruff to ensure code meets project standards."""
diff_flag, fix_flag = "", ""
if fix:
fix_flag = "--fix"
if diff:
diff_flag = "--diff"
c.run(f"{CMD_PREFIX}isort {check_flag} {diff_flag} .")


@task
def flake8(c):
"""Check code for PEP8 compliance via Flake8."""
c.run(f"{CMD_PREFIX}flake8 {PKG_PATH} tasks.py")
c.run(f"{CMD_PREFIX}/ruff check {diff_flag} {fix_flag} .", pty=PTY)


@task
def lint(c, diff=False):
def lint(c, fix=False, diff=False):
"""Check code style via linting tools."""
isort(c, check=True, diff=diff)
black(c, check=True, diff=diff)
flake8(c)
ruff(c, fix=fix, diff=diff)


@task
Expand Down
Loading

0 comments on commit 06970fe

Please sign in to comment.