Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/FUNDING.yml

This file was deleted.

16 changes: 8 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
77 changes: 19 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,90 +1,51 @@
name: CI

on:
push:
branches:
- main
- main
pull_request:

jobs:

dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.x"
- run: python -m pip install --upgrade pip build wheel twine
- run: python -m build --sdist --wheel
- run: python -m twine check dist/*
- uses: astral-sh/setup-uv@v7
- run: uvx --from build pyproject-build --sdist --wheel
- run: uvx twine check dist/*
- uses: actions/upload-artifact@v7
with:
path: dist/*

lint:
runs-on: ubuntu-latest
strategy:
matrix:
lint-command:
- bandit -r . -x ./tests
- black --check --diff .
- flake8 .
- isort --check-only --diff .
- pydocstyle .
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: 'linter-requirements.txt'
- run: python -m pip install -r linter-requirements.txt
- run: ${{ matrix.lint-command }}

PyTest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"

- "3.12"
- "3.13"
- "3.14"
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install --upgrade pip setuptools
- run: python -m pip install -e .[test]
- run: relint --version
- run: py.test --cov=.
- uses: codecov/codecov-action@v6


- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- run: uv run relint --version
- run: uv run --group test py.test --cov=.
- uses: codecov/codecov-action@v6
extras:
runs-on: ubuntu-latest
strategy:
matrix:
extras:
- "regex"

steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.x"
- run: python -m pip install --upgrade pip setuptools
- run: python -m pip install -e .[test,${{ matrix.extras }}]
- run: relint --version
- run: py.test --cov=.
- uses: astral-sh/setup-uv@v7
- run: uv run relint --version
- run: uv run --group test --extra ${{ matrix.extras }} py.test --cov=.
- uses: codecov/codecov-action@v6

analyze:
name: CodeQL Analyze
needs: [PyTest,extras]
needs: [PyTest, extras]
runs-on: ubuntu-latest
permissions:
actions: read
Expand All @@ -93,7 +54,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ python ]
language: [python]
steps:
- name: Checkout
uses: actions/checkout@v6
Expand Down
35 changes: 21 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
name: Release

on:
release:
types: [published]

workflow_dispatch:
jobs:

PyPi:
pypi-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.x"
- run: python -m pip install --upgrade pip build wheel twine
- run: python -m build --sdist --wheel
- run: python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- run: uvx --from build pyproject-build --sdist --wheel
- uses: actions/upload-artifact@v7
with:
name: release-dists
path: dist/
pypi-publish:
runs-on: ubuntu-latest
needs:
- pypi-build
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: release-dists
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
default_language_version:
python: python3.14
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: check-ast
- id: check-json
- id: pretty-format-json
args: [--autofix]
- id: check-toml
- id: check-xml
- id: check-symlinks
- id: debug-statements
- id: destroyed-symlinks
- id: check-executables-have-shebangs
- id: end-of-file-fixer
- id: name-tests-test
args: ["--pytest-test-first"]
exclude: ^tests/fixtures.py$
- id: no-commit-to-branch
args: [--branch, main]
- id: detect-private-key
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py312-plus]
- repo: https://github.com/hukkin/mdformat
rev: 1.0.0
hooks:
- id: mdformat
additional_dependencies:
- mdformat-beautysh
- mdformat-footnote
- mdformat-gfm
- mdformat-gfm-alerts
- mdformat-ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.14
hooks:
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/google/yamlfmt
rev: v0.21.0
hooks:
- id: yamlfmt
ci:
skip:
- no-commit-to-branch
14 changes: 7 additions & 7 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- id: relint
name: relint
description: 'Write your own linting rules using regular expressions.'
entry: relint
args: [--git-diff]
language: python
types: [file]
- id: relint
name: relint
description: 'Write your own linting rules using regular expressions.'
entry: relint
args: [--git-diff]
language: python
types: [file]
7 changes: 0 additions & 7 deletions SECURITY.md

This file was deleted.

5 changes: 0 additions & 5 deletions linter-requirements.txt

This file was deleted.

50 changes: 34 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,26 @@ classifiers = [
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
]
requires-python = ">=3.8"
requires-python = ">=3.12"
dependencies = [
"PyYAML",
"rich",
]

[project.optional-dependencies]
regex = [
"regex"
]

[dependency-groups]
dev = [
{ include-group = "test" },
]
test = [
"pytest",
"pytest-cov",
"pytest-mock",
]
regex = [
"regex"
]

[project.scripts]
relint = "relint.__main__:main"
Expand All @@ -63,16 +68,29 @@ source = ["relint"]
[tool.coverage.report]
show_missing = true

[tool.isort]
atomic = true
line_length = 88
multi_line_output = 3
force_grid_wrap = 0
known_first_party = "relint, tests"
include_trailing_comma = true
use_parentheses = true
default_section = "THIRDPARTY"
combine_as_imports = true
[tool.ruff]
src = ["relint", "tests"]

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"S", # flake8-bandit
"D", # pydocstyle
"UP", # pyupgrade
"B", # flake8-bugbear
"C", # flake8-comprehensions
]

ignore = ["B904", "D1", "E501", "S101"]

[tool.ruff.lint.isort]
combine-as-imports = true
split-on-trailing-comma = true
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
force-wrap-aliases = true

[tool.pydocstyle]
add_ignore = "D1"
[tool.ruff.lint.pydocstyle]
convention = "pep257"
18 changes: 10 additions & 8 deletions relint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ def parse_args(args=None):
action="store_true",
help="Do not output warnings. Could be useful when using relint in CI.",
)
parser.add_argument(
"--summarize",
action="store_true",
help="Summarize the output by grouping matches by test.",
),
(
parser.add_argument(
"--summarize",
action="store_true",
help="Summarize the output by grouping matches by test.",
),
)
parser.add_argument(
"--code-padding",
type=int,
Expand Down Expand Up @@ -89,9 +91,9 @@ def main(args=None):
if args.diff:
output = sys.stdin.read()
elif args.git_diff:
output = subprocess.check_output( # nosec
["git", "diff", "--staged", "--unified=0", "--no-color"],
universal_newlines=True,
output = subprocess.check_output(
["git", "diff", "--staged", "--unified=0", "--no-color"], # noqa: S607
text=True,
)
if args.diff or args.git_diff:
changed_content = parse_diff(output)
Expand Down
4 changes: 3 additions & 1 deletion relint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def load_config(path, fail_warnings, ignore_warnings):
raise ConfigError("Error parsing your relint config file.") from e
except TypeError:
warnings.warn(
"Your relint config is empty, no tests were executed.", UserWarning
"Your relint config is empty, no tests were executed.",
UserWarning,
stacklevel=2,
)
except (AttributeError, ValueError) as e:
raise ConfigError(
Expand Down
Loading