Skip to content

Commit 02d5cae

Browse files
refactor: move remaining config into pyproject.toml
Translate German comments to English. Enable ruff rules for the retired tools (E/W/F/I/D/UP/C901/TRY), move isort and pylint settings into pyproject.toml, and delete setup.cfg and .pylintrc. Makefile, pre-commit and CI now rely on ruff instead of flake8/pycodestyle/pydocstyle.
1 parent 97c0a28 commit 02d5cae

10 files changed

Lines changed: 54 additions & 50 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ jobs:
3535
token: ${{ secrets.CODECOV_TOKEN }}
3636
- name: Run lint
3737
run: |
38-
pip install black pycodestyle pylint flake8 mypy pydocstyle vulture pytest ruff setuptools
38+
pip install black pylint mypy vulture pytest ruff setuptools
3939
sudo npm install -g pyright
4040
make lint

‎.pre-commit-config.yaml‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ repos:
1616
rev: 23.3.0
1717
hooks:
1818
- id: black
19-
- repo: https://github.com/PyCQA/flake8
20-
rev: 6.0.0
19+
- repo: local
2120
hooks:
22-
- id: flake8
21+
- id: ruff-check
22+
name: ruff check
23+
entry: ruff check --force-exclude
24+
language: system
25+
'types': [python]
26+
- id: ruff-format
27+
name: ruff format
28+
entry: ruff format --force-exclude
29+
language: system
30+
'types': [python]
2331
- repo: local
2432
hooks:
2533
- id: unittest

‎.pylintrc‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎Makefile‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,9 @@ auto-style: ## Style the code
7171
else echo "SKIPPED. Run '$(PIP) install black' first." >&2 ; fi
7272

7373
code-style: ## Test the code style
74-
@echo Pycodestyle...
75-
@if type pycodestyle >/dev/null 2>&1 ; then pycodestyle *.py $(SRC_CORE)/*.py $(SRC_TEST)/*.py ; \
76-
else echo "SKIPPED. Run '$(PIP) install pycodestyle' first." >&2 ; fi
77-
@echo Pydocstyle...
78-
@if type pydocstyle >/dev/null 2>&1 ; then pydocstyle $(SRC_CORE)/*.py $(SRC_TEST)/*.py ; \
79-
else echo "SKIPPED. Run '$(PIP) install pydocstyle' first." >&2 ; fi
74+
@echo Ruff format...
75+
@if type ruff >/dev/null 2>&1 ; then ruff format --check . ; \
76+
else echo "SKIPPED. Run '$(PIP) install ruff' first." >&2 ; fi
8077

8178
code-count: ## Count the code
8279
@if type cloc >/dev/null 2>&1 ; then cloc $(SRC_CORE) ; \
@@ -89,9 +86,6 @@ code-lint: code-style ## Lint the code
8986
@echo Ruff...
9087
@if type ruff >/dev/null 2>&1 ; then ruff check . ; \
9188
else echo "SKIPPED. Run '$(PIP) install ruff' first." >&2 ; fi
92-
@echo Flake...
93-
@if type flake8 >/dev/null 2>&1 ; then flake8 . ; \
94-
else echo "SKIPPED. Run '$(PIP) install flake8' first." >&2 ; fi
9589

9690
code-check-types: ## Check the code types
9791
@echo Pyright...

‎pyproject.toml‎

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,40 @@ dynamic = ["version"]
2222
[tool.setuptools.dynamic]
2323
version = { attr = "things.__version__" }
2424

25-
# Ruff-Konfiguration: Ziel ist die älteste unterstützte Version
26-
# (pyproject.toml: requires-python >= 3.11, CI testet 3.11+).
27-
# Damit sind moderne Annotations-Syntaxen (PEP 585/604) ok.
25+
# Ruff configuration: target the oldest supported version
26+
# (pyproject.toml: requires-python >= 3.11, CI tests 3.11+).
27+
# This allows modern annotation syntax (PEP 585/604).
2828
[tool.ruff]
2929
target-version = "py311"
30+
line-length = 88
3031

3132
[tool.ruff.lint]
32-
# TRY004 will TypeError statt ValueError bei falschem Typ. ValueError ist
33-
# hier API-Vertrag: things/api.get() fängt ValueError, Tests erwarten ihn.
34-
ignore = ["TRY004"]
35-
# C901 kennt nur flake8 (max-complexity = 10 in setup.cfg). Die noqa dafür
36-
# in things/api.py muss bleiben; Ruff soll sie als verwendet werten.
37-
external = ["C901"]
33+
# E/W mirror the old flake8/pycodestyle setup (E501 and friends stay ignored:
34+
# layout is owned by `ruff format`). I/D take over isort/pydocstyle, C901
35+
# takes over flake8 max-complexity, UP keeps the annotations modern.
36+
select = ["E", "W", "F", "I", "D", "UP", "C901", "TRY"]
37+
# TRY004 wants TypeError instead of ValueError for wrong types. ValueError
38+
# is part of the API contract here: things/api.get() catches ValueError
39+
# and the tests expect it.
40+
# The D-ignores mirror the old pydocstyle section from setup.cfg. D417 and
41+
# TRY003 are new: ruff is stricter than the tools it replaces here, and both
42+
# touch the public API shape (docstring/kwargs style, exception classes),
43+
# so they stay off instead of churning user-visible code.
44+
ignore = ["TRY004", "TRY003", "E501", "E203", "E231", "E241", "E202", "D102", "D212", "D213", "D413", "D203", "D409", "D405", "D406", "D407", "D417"]
45+
46+
[tool.ruff.lint.isort]
47+
force-sort-within-sections = true
48+
lines-after-imports = 2
49+
50+
[tool.ruff.lint.mccabe]
51+
max-complexity = 10
52+
53+
[tool.isort]
54+
force_sort_within_sections = true
55+
lines_after_imports = 2
56+
57+
[tool.pylint."MESSAGES CONTROL"]
58+
disable = ["missing-function-docstring", "C0412"]
3859

3960
[tool.pytest.ini_options]
4061
doctest_optionflags = ["NORMALIZE_WHITESPACE", "ELLIPSIS"]

‎setup.cfg‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎setup.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44

5-
from setuptools import find_packages, setup # type: ignore # pylint: disable=import-error
5+
import setuptools # type: ignore # pylint: disable=import-error
66

77

88
def package_files(directory):
@@ -15,13 +15,13 @@ def package_files(directory):
1515
return paths
1616

1717

18-
setup(
18+
setuptools.setup(
1919
# name stays here (not only in pyproject.toml): py2app's finalize hook
2020
# reads it before pyproject metadata is merged; without it every
2121
# setup.py invocation fails with "no script, modules or dest_base specified".
2222
name="things.py",
2323
app=[""],
24-
packages=find_packages(),
24+
packages=setuptools.find_packages(),
2525
data_files=package_files(""),
2626
options={"py2app": {"argv_emulation": False}}, # pyright: ignore[reportArgumentType]
2727
setup_requires=["py2app"],

‎tests/test_things.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
import sqlite3
77
import time
88
import tracemalloc
9+
from typing import cast
910
import unittest
1011
import unittest.mock
11-
from typing import cast
1212

1313
import things
1414
import things.database
1515

16+
1617
tracemalloc.start()
1718

1819
TEST_DATABASE_FILEPATH = "tests/main.sqlite"

‎things/api.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
"""
99

1010
import os # pylint: disable=C0412
11-
import urllib.parse
1211
from shlex import quote
12+
import urllib.parse
1313

1414
from things.database import Database
1515

16+
1617
# --------------------------------------------------
1718
# Core functions
1819
# --------------------------------------------------

‎things/database.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
import plistlib
99
import re
1010
import sqlite3
11-
import weakref
1211
from textwrap import dedent
12+
import weakref
13+
1314

1415
# --------------------------------------------------
1516
# Core constants

0 commit comments

Comments
 (0)