Skip to content

Commit

Permalink
Migrate from several linters to Ruff (#229)
Browse files Browse the repository at this point in the history
* Move coverage configs to pyproject.toml

* Replace sevral linters with ruff
  • Loading branch information
Secrus authored Aug 16, 2024
1 parent 7e7687c commit 76d1957
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 55 deletions.
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

6 changes: 0 additions & 6 deletions .isort.cfg

This file was deleted.

39 changes: 8 additions & 31 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: "24.4.2"
hooks:
- id: black
language_version: python3.8

- repo: https://github.com/PyCQA/isort
rev: "5.13.2"
hooks:
- id: isort
files: \.py$

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.10.0"
hooks:
Expand All @@ -19,12 +7,6 @@ repos:
- httpx
exclude: docs/.*|tests/.*|noxfile.py

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
args: [--prose-wrap, always]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
hooks:
Expand All @@ -38,19 +20,8 @@ repos:
- id: forbid-new-submodules
- id: trailing-whitespace

- repo: https://github.com/PyCQA/flake8
rev: "7.0.0"
hooks:
- id: flake8

- repo: https://github.com/PyCQA/pydocstyle.git
rev: "6.3.0"
hooks:
- id: pydocstyle
files: src/.*\.py$

- repo: https://github.com/asottile/blacken-docs
rev: "1.16.0"
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.18.0"
hooks:
- id: blacken-docs

Expand All @@ -59,3 +30,9 @@ repos:
hooks:
- id: pyproject-fmt
args: [--indent, "4"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.0
hooks:
- id: ruff
- id: ruff-format
2 changes: 0 additions & 2 deletions .pydocstyle

This file was deleted.

6 changes: 2 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ development.

This codebase uses the following tools for enforcing a code convention:

- [black] for code formatting
- [isort] for import sorting
- [ruff] for code formatting and linting
- [mypy] for static type checking
- [pre-commit] for managing all the linters

Expand All @@ -63,8 +62,7 @@ To run all the linters:
$ nox -s lint
```

[black]: https://github.com/psf/black
[isort]: https://github.com/timothycrosley/isort
[ruff]: https://github.com/astral-sh/ruff
[mypy]: https://github.com/python/mypy
[pre-commit]: https://pre-commit.com/

Expand Down
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,40 @@ dynamic = [
[project.urls]
"GitHub" = "https://github.com/pypa/installer"

[tool.ruff]
fix = true
src = ["src"]
extend-exclude = [
"noxfile.py",
"docs/*"
]

[tool.ruff.lint]
select = [
"E",
"F",
"W",
"I",
"D",
]
ignore = [
"D105", "D203", "D213", "E501"
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["D"]
"tools/*" = ["D"]

[tool.ruff.lint.isort]
known-first-party = ["src"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if TYPE_CHECKING:",
]

[tool.mypy]
files = "src,tools"
strict = true
Expand Down
4 changes: 2 additions & 2 deletions src/installer/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
class InvalidRecordEntry(Exception):
"""Raised when a RecordEntry is not valid, due to improper element values or count."""

def __init__(
def __init__( # noqa: D107
self, elements: Iterable[str], issues: Iterable[str]
) -> None: # noqa: D107
) -> None:
super().__init__(", ".join(issues))
self.issues = issues
self.elements = elements
Expand Down
3 changes: 1 addition & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tests for installer.utils
"""
"""Tests for installer.utils"""

import base64
import hashlib
Expand Down

0 comments on commit 76d1957

Please sign in to comment.