diff --git a/.github/workflows/code-style.yaml b/.github/workflows/code-style.yaml deleted file mode 100644 index 06f9d560..00000000 --- a/.github/workflows/code-style.yaml +++ /dev/null @@ -1,49 +0,0 @@ -name: code-style -concurrency: - group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }} - cancel-in-progress: true -on: # yamllint disable-line rule:truthy - pull_request: - push: - branches: [main] - workflow_dispatch: - -jobs: - style: - timeout-minutes: 10 - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Setup Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: '3.9' - architecture: 'x64' - - name: Install dependencies - run: | - python -m pip install --progress-bar off --upgrade pip setuptools - python -m pip install --progress-bar off .[style] - - name: Run isort - uses: isort/isort-action@master - - name: Run black - uses: psf/black@stable - with: - options: "--check --verbose" - - name: Run Ruff - run: ruff check . - - name: Run codespell - uses: codespell-project/actions-codespell@master - with: - check_filenames: true - check_hidden: true - skip: './.git,./build,./.mypy_cache,./.pytest_cache' - ignore_words_file: ./.codespellignore - - name: Run pydocstyle - run: pydocstyle . - - name: Run bibclean - run: bibclean-check doc/references.bib - - name: Run toml-sort - run: toml-sort pyproject.toml --check - - name: Run yamllint - run: yamllint . -c .yamllint.yaml --strict diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 71eb6acf..2af32bc8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,3 @@ -ci: - skip: [codespell, pydocstyle, yamllint] - repos: - repo: https://github.com/pycqa/isort rev: 5.13.2 @@ -8,25 +5,22 @@ repos: - id: isort files: template - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.0 - hooks: - - id: black - args: [--quiet] - files: template - - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.1.8 hooks: - id: ruff - args: [--fix, --exit-non-zero-on-fix] + name: ruff linter + args: [--fix] + files: template + - id: ruff-format + name: ruff formatter files: template - repo: https://github.com/codespell-project/codespell rev: v2.2.6 hooks: - id: codespell - args: [--check-filenames, --ignore-words=.codespellignore] + args: [--write-changes] - repo: https://github.com/pycqa/pydocstyle rev: 6.3.0 diff --git a/README.md b/README.md index 0db66652..71f7f3bb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/) [![codecov](https://codecov.io/gh/mscheltienne/template-python/branch/main/graph/badge.svg?token=KRYRRUXDYY)](https://codecov.io/gh/mscheltienne/template-python) diff --git a/pyproject.toml b/pyproject.toml index 51b73adf..2f461e6a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,10 +63,14 @@ doc = [ full = [ 'template[all]', ] +stubs = [ + 'isort', + 'mypy', + 'ruff', +] style = [ 'bibclean', - 'black', - 'codespell', + 'codespell[toml]>=2.2.4', 'isort', 'pydocstyle[toml]', 'ruff', @@ -88,20 +92,11 @@ homepage = 'https://github.com/mscheltienne/template-python' source = 'https://github.com/mscheltienne/template-python' tracker = 'https://github.com/mscheltienne/template-python/issues' -[tool.black] -extend-exclude = ''' -( - __pycache__ - | .github - | setup.py - | doc/ - | examples/ - | tutorials/ -) -''' -include = '\.pyi?$' -line-length = 88 -target-version = ['py39'] +[tool.codespell] +check-filenames = true +check-hidden = true +ignore-words = '.codespellignore' +skip = 'build,.git,.mypy_cache,.pytest_cache' [tool.coverage.report] exclude_lines = [ @@ -152,6 +147,11 @@ extend-exclude = [ 'setup.py', ] line-length = 88 +select = ["E", "F", "W"] +target-version = 'py39' + +[tool.ruff.format] +docstring-code-format = true [tool.ruff.per-file-ignores] '__init__.py' = ['F401'] diff --git a/template/utils/_docs.py b/template/utils/_docs.py index 70caba3c..ca8de61f 100644 --- a/template/utils/_docs.py +++ b/template/utils/_docs.py @@ -16,9 +16,7 @@ docdict: dict[str, str] = dict() # ---------------------------------- verbose --------------------------------- -docdict[ - "verbose" -] = """ +docdict["verbose"] = """ verbose : int | str | bool | None Sets the verbosity level. The verbosity increases gradually between ``"CRITICAL"``, ``"ERROR"``, ``"WARNING"``, ``"INFO"`` and ``"DEBUG"``. If None is provided, the @@ -75,16 +73,16 @@ def fill_doc(f: Callable[..., Any]) -> Callable[..., Any]: def _indentcount_lines(lines: list[str]) -> int: """Minimum indent for all lines in line list. - >>> lines = [' one', ' two', ' three'] + >>> lines = [" one", " two", " three"] >>> indentcount_lines(lines) 1 >>> lines = [] >>> indentcount_lines(lines) 0 - >>> lines = [' one'] + >>> lines = [" one"] >>> indentcount_lines(lines) 1 - >>> indentcount_lines([' ']) + >>> indentcount_lines([" "]) 0 """ indent = sys.maxsize @@ -125,7 +123,7 @@ def copy_doc(source: Callable[..., Any]) -> Callable[..., Any]: >>> class B(A): ... @copy_doc(A.m1) ... def m1(): - ... ''' this gets appended''' + ... '''this gets appended''' ... pass >>> print(B.m1.__doc__) Docstring for m1 this gets appended diff --git a/template/utils/logs.py b/template/utils/logs.py index 07415453..b3ca1307 100644 --- a/template/utils/logs.py +++ b/template/utils/logs.py @@ -82,7 +82,7 @@ def set_log_level(verbose: Optional[Union[bool, str, int]]) -> None: class _LoggerFormatter(logging.Formatter): - """Format string Syntax.""" + """Format string syntax.""" # Format string syntax for the different Log levels _formatters = dict()