Skip to content

Commit

Permalink
Cleanup linters and CI tools
Browse files Browse the repository at this point in the history
- black was not used for ages in CI, ruff can be used for formatting too
- flake8 is overseeded by ruff
- pydocstyle was deprecated in favour of ruff, that we are already using.
- Creating a new category of optional deps for testing
- Fix ruff configuration warning
- Adding ruff to pre-commit, just check
- Adapted tox configuration
  • Loading branch information
joselsegura committed Jan 13, 2025
1 parent 3c62e61 commit 863b5de
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 65 deletions.
42 changes: 12 additions & 30 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,23 @@ on:
- pull_request

jobs:
ruff:
pre-commit-hooks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
strategy:
matrix:
hook_id:
- "trailing-whitespaces"
- "end-of-file-fixer"
- "check-yaml"
- "debug-statements"
- "ruff"
- "pyupgrade"

pre-commit-flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.12'
- uses: pre-commit/action@v3.0.1
with:
extra_args: flake8 --all-files

pre-commit-pyupgrade:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: pre-commit/action@v3.0.1
with:
extra_args: pyupgrade --all-files

pre-commit-pydocstyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: pre-commit/action@v3.0.1
with:
extra_args: pydocstyle --all-files
extra_args: ${{ matrix.hook_id }}
28 changes: 10 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
exclude: "doc|research|demos"
repos:
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args: [--safe, --quiet, --line-length, "100"]
language_version: python3
require_serial: true
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand All @@ -18,19 +11,18 @@ repos:
language_version: python3
- id: debug-statements
language_version: python3

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.0
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
# - id: ruff-format

- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
language_version: python3
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
language_version: python3
args: [--extend-ignore=E501,--extend-ignore=E203]
- repo: https://gitlab.com/pycqa/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
language_version: python3
17 changes: 8 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,22 @@ Homepage = "https://github.com/RedHatInsights/insights-ccx-messaging"
ccx-messaging = "ccx_messaging.command_line:ccx_messaging"

[project.optional-dependencies]
test = [
"pytest",
"pytest-cov",
"freezegun"
]
dev = [
"black",
"coverage",
"flake8",
"freezegun",
"pycco",
"pycodestyle",
"pydocstyle",
"pylint",
"pytest",
"pytest-cov",
"ruff"
]

[tool.setuptools_scm]

[tool.ruff]
line-length = 100

[tool.ruff.lint]
select = ["E", "F", "W", "UP", "C", "D"]
ignore = ["D211", "C401", "D203", "D213", "UP006", "UP007", "UP009", "UP015", "UP035"]
line-length = 100
9 changes: 1 addition & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@ envlist = py{311,312}
usedevelop = True
deps = -r requirements.txt
install_command = pip install {opts} {packages}
extras = dev
extras = test
commands =
pytest -v --cov=ccx_messaging --cov-fail-under=70
pytest -v --cov=ccx_messaging --cov-report=xml

[pycodestyle]
max-line-length = 100

[flake8]
extend-ignore = E203
max-line-length = 100

[gh]
python =
3.12 = py312
Expand Down

0 comments on commit 863b5de

Please sign in to comment.