diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 260b6b21..b263dd9d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,12 @@ repos: - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - files: template - - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.5.7 hooks: - id: ruff name: ruff linter args: [--fix, --show-fixes] - files: template - id: ruff-format name: ruff formatter - files: template - repo: https://github.com/codespell-project/codespell rev: v2.3.0 @@ -23,13 +15,6 @@ repos: args: [--write-changes] additional_dependencies: [tomli] - - repo: https://github.com/pycqa/pydocstyle - rev: 6.3.0 - hooks: - - id: pydocstyle - files: template - additional_dependencies: [tomli] - - repo: https://github.com/mscheltienne/bibclean rev: 0.8.0 hooks: diff --git a/doc/conf.py b/doc/conf.py index 39d10e00..8bb638db 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -4,6 +4,7 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html from __future__ import annotations + import inspect import subprocess import sys @@ -24,7 +25,7 @@ project = "template-python" author = "Mathieu Scheltienne" -copyright = f"{date.today().year}, {author}" +copyright = f"{date.today().year}, {author}" # noqa: A001 release = template.__version__ package = template.__name__ gh_url = "https://github.com/mscheltienne/template-python" @@ -95,7 +96,7 @@ - """, + """, # noqa: E501 "class": "", }, ], diff --git a/pyproject.toml b/pyproject.toml index 8e745fdf..4d980302 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,16 +67,14 @@ full = [ 'template[all]', ] stubs = [ - 'isort', 'mypy', - 'ruff>=0.1.8', + 'ruff>=0.6.0', ] style = [ 'bibclean', 'codespell[toml]>=2.2.4', - 'isort', - 'pydocstyle[toml]', - 'ruff>=0.1.8', + 'pre-commit', + 'ruff>=0.6.0', 'toml-sort', 'yamllint', ] @@ -120,33 +118,13 @@ omit = [ '**/tests/**', ] -[tool.isort] -extend_skip_glob = [ - 'doc/*', - 'examples/*', - 'tutorials/*', -] -line_length = 88 -multi_line_output = 3 -profile = 'black' -py_version = 39 - -[tool.pydocstyle] -add_ignore = 'D100,D104,D107' -convention = 'numpy' -ignore-decorators = '(copy_doc|property|.*setter|.*getter|pyqtSlot|Slot)' -match = '^(?!__init__|test_).*\.py' -match-dir = '^template.*' - [tool.pytest.ini_options] addopts = ['--color=yes', '--cov-report=', '--durations=20', '--junit-xml=junit-results.xml', '--strict-config', '--tb=short', '-ra', '-v'] junit_family = 'xunit2' minversion = '8.0' [tool.ruff] -extend-exclude = [ - 'doc', -] +extend-exclude = [] line-length = 88 [tool.ruff.format] @@ -155,15 +133,23 @@ line-ending = "lf" [tool.ruff.lint] ignore = [] -select = ['A', 'B', 'E', 'F', 'G', 'LOG', 'NPY', 'PIE', 'PT', 'T20', 'UP', 'W'] +select = ['A', 'B', 'D', 'E', 'F', 'G', 'I', 'LOG', 'NPY', 'PIE', 'PT', 'T20', 'UP', 'W'] [tool.ruff.lint.per-file-ignores] '*' = [ 'B904', # 'Within an except clause, raise exceptions with raise ... from ...' + 'D100', # 'Missing docstring in public module' + 'D104', # 'Missing docstring in public package' + 'D107', # 'Missing docstring in __init__' 'UP007', # 'Use `X | Y` for type annotations', requires python 3.10 ] '*.pyi' = ['E501'] '__init__.py' = ['F401'] +'tutorials/*' = ['D205', 'D400', 'T201'] + +[tool.ruff.lint.pydocstyle] +convention = 'numpy' +ignore-decorators = ["template.utils._docs.copy_doc"] [tool.setuptools] include-package-data = false diff --git a/template/commands/main.py b/template/commands/main.py index c14bfd48..9f7e9197 100644 --- a/template/commands/main.py +++ b/template/commands/main.py @@ -6,8 +6,8 @@ @click.group() -def run() -> None: # noqa: D401 - """Main package entry-point.""" +def run() -> None: + """Main package entry-point.""" # noqa: D401 run.add_command(sys_info) diff --git a/tools/stubgen.py b/tools/stubgen.py index c8855d66..05c0da64 100644 --- a/tools/stubgen.py +++ b/tools/stubgen.py @@ -4,7 +4,6 @@ from importlib import import_module from pathlib import Path -import isort from mypy import stubgen import template @@ -33,7 +32,6 @@ ) stubs = list(directory.rglob("*.pyi")) config = str(directory.parent / "pyproject.toml") -config_isort = isort.settings.Config(config) # expand docstrings and inject into stub files for stub in stubs: @@ -59,9 +57,12 @@ method.body[0].value.value = docstring unparsed = ast.unparse(module_ast) stub.write_text(unparsed, encoding="utf-8") - # sort imports - isort.file(stub, config=config_isort) # run ruff to improve stub style +execution = subprocess.run( + ["ruff", "check", str(directory), "--fix", "--unsafe-fixes", "--config", config] +) +if execution.returncode: + sys.exit(execution.returncode) execution = subprocess.run(["ruff", "format", str(directory), "--config", config]) sys.exit(execution.returncode)