diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index a1322e2..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: 2 -updates: - - package-ecosystem: github-actions - directory: "/" - assignees: - - redeboer - labels: - - 🖱️ DX - schedule: - interval: monthly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24fea69..2c5622c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,8 @@ name: CI concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: |- + ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} env: PYTHONHASHSEED: "0" diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index d64f197..5234093 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -11,6 +11,6 @@ jobs: update_release_draft: runs-on: ubuntu-22.04 steps: - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/requirements.yml b/.github/workflows/requirements.yml index b2562f2..ec42f28 100644 --- a/.github/workflows/requirements.yml +++ b/.github/workflows/requirements.yml @@ -2,7 +2,8 @@ name: Requirements concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: |- + ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} on: pull_request: diff --git a/.gitpod.yml b/.gitpod.yml index 3aab122..29d758d 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,6 +1,6 @@ tasks: - - init: pyenv local 3.8 - - init: pip install -c .constraints/py3.8.txt -e .[dev] + - init: pyenv local 3.9 + - init: pip install -c .constraints/py3.9.txt -e .[dev] github: prebuilds: @@ -22,7 +22,6 @@ vscode: - executablebookproject.myst-highlight - github.vscode-github-actions - github.vscode-pull-request-github - - ms-python.black-formatter - ms-python.mypy-type-checker - ms-python.python - ms-python.vscode-pylance @@ -31,10 +30,9 @@ vscode: - ms-vsliveshare.vsliveshare - redhat.vscode-yaml - ryanluker.vscode-coverage-gutters - - Soulcode.vscode-unwanted-extensions + - soulcode.vscode-unwanted-extensions - stkb.rewrap - streetsidesoftware.code-spell-checker - tamasfe.even-better-toml - trentrand.git-commit-helper-vscode - - tyriar.sort-lines - yzhang.markdown-all-in-one diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ce5ea9..f1f0d45 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,40 @@ repos: - id: check-hooks-apply - id: check-useless-excludes + - repo: https://github.com/kynan/nbstripout + rev: 0.7.1 + hooks: + - id: nbstripout + args: + - --extra-keys + - | + cell.attachments + cell.metadata.code_folding + cell.metadata.id + cell.metadata.pycharm + cell.metadata.user_expressions + metadata.celltoolbar + metadata.colab.name + metadata.colab.provenance + metadata.interpreter + metadata.notify_time + metadata.toc + metadata.toc-autonumbering + metadata.toc-showcode + metadata.toc-showmarkdowntxt + metadata.toc-showtags + metadata.varInspector + metadata.vscode + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.0 + hooks: + - id: ruff + args: [--fix] + types_or: [python, pyi, jupyter] + - id: ruff-format + types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -31,16 +65,22 @@ repos: args: ["--django"] - id: trailing-whitespace - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.2.0 + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 hooks: - - id: black - - id: black-jupyter - args: - - --line-length=85 - types_or: - - jupyter + - id: prettier + + - repo: https://github.com/ComPWA/mirrors-taplo + rev: v0.8.1 + hooks: + - id: taplo + - repo: https://github.com/pappasam/toml-sort + rev: v0.23.1 + hooks: + - id: toml-sort + args: + - --in-place - repo: https://github.com/ComPWA/policy rev: 0.2.6 hooks: @@ -77,56 +117,8 @@ repos: types: - python - - repo: https://github.com/kynan/nbstripout - rev: 0.7.1 - hooks: - - id: nbstripout - args: - - --extra-keys - - | - cell.attachments - cell.metadata.code_folding - cell.metadata.id - cell.metadata.pycharm - cell.metadata.user_expressions - metadata.celltoolbar - metadata.colab.name - metadata.colab.provenance - metadata.interpreter - metadata.notify_time - metadata.toc - metadata.toc-autonumbering - metadata.toc-showcode - metadata.toc-showmarkdowntxt - metadata.toc-showtags - metadata.varInspector - metadata.vscode - - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v4.0.0-alpha.8 - hooks: - - id: prettier - - repo: https://github.com/ComPWA/mirrors-pyright rev: v1.1.352 hooks: - id: pyright - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.0 - hooks: - - id: ruff - args: [--fix] - types_or: [python, pyi, jupyter] - - - repo: https://github.com/ComPWA/mirrors-taplo - rev: v0.8.1 - hooks: - - id: taplo - - - repo: https://github.com/pappasam/toml-sort - rev: v0.23.1 - hooks: - - id: toml-sort - args: - - --in-place diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 65d9a54..82d6e46 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -8,7 +8,6 @@ "executablebookproject.myst-highlight", "github.vscode-github-actions", "github.vscode-pull-request-github", - "ms-python.black-formatter", "ms-python.mypy-type-checker", "ms-python.python", "ms-python.vscode-pylance", @@ -17,21 +16,22 @@ "ms-vsliveshare.vsliveshare", "redhat.vscode-yaml", "ryanluker.vscode-coverage-gutters", - "Soulcode.vscode-unwanted-extensions", + "soulcode.vscode-unwanted-extensions", "stkb.rewrap", "streetsidesoftware.code-spell-checker", "tamasfe.even-better-toml", "trentrand.git-commit-helper-vscode", - "tyriar.sort-lines", "yzhang.markdown-all-in-one" ], "unwantedRecommendations": [ "bungcip.better-toml", "davidanson.vscode-markdownlint", "garaioag.garaio-vscode-unwanted-recommendations", + "ms-python.black-formatter", "ms-python.flake8", "ms-python.isort", "ms-python.pylint", - "travisillig.vscode-json-stable-stringify" + "travisillig.vscode-json-stable-stringify", + "tyriar.sort-lines" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 0b14d0d..5aa7320 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,8 @@ { "[git-commit]": { - "editor.rulers": [72], + "editor.rulers": [ + 72 + ], "rewrap.wrappingColumn": 72 }, "[ipynb]": { @@ -19,14 +21,17 @@ "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }, - "editor.defaultFormatter": "ms-python.black-formatter", - "editor.rulers": [88] + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.rulers": [ + 88 + ] }, "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "black-formatter.importStrategy": "fromEnvironment", - "coverage-gutters.coverageFileNames": ["coverage.xml"], + "coverage-gutters.coverageFileNames": [ + "coverage.xml" + ], "coverage-gutters.coverageReportFileName": "**/htmlcov/index.html", "coverage-gutters.showGutterCoverage": false, "coverage-gutters.showLineCoverage": true, @@ -34,28 +39,42 @@ "diffEditor.experimental.showMoves": true, "editor.formatOnSave": true, "git.rebaseWhenSync": true, - "github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"], + "github-actions.workflows.pinned.workflows": [ + ".github/workflows/ci.yml" + ], "gitlens.telemetry.enabled": false, "livePreview.defaultPreviewPath": "docs/_build/html", "multiDiffEditor.experimental.enabled": true, - "mypy-type-checker.args": ["--config-file=${workspaceFolder}/pyproject.toml"], + "mypy-type-checker.args": [ + "--config-file=${workspaceFolder}/pyproject.toml" + ], "mypy-type-checker.importStrategy": "fromEnvironment", + "notebook.codeActionsOnSave": { + "notebook.source.organizeImports": "explicit" + }, + "notebook.formatOnSave.enabled": true, "notebook.gotoSymbols.showAllSymbols": true, "python.analysis.autoImportCompletions": false, "python.analysis.inlayHints.pytestParameters": true, "python.analysis.typeCheckingMode": "strict", "python.languageServer": "Pylance", - "python.testing.pytestArgs": ["--color=no", "--no-cov"], + "python.testing.pytestArgs": [ + "--color=no", + "--no-cov" + ], "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, + "redhat.telemetry.enabled": false, "rewrap.wrappingColumn": 88, "ruff.enable": true, + "ruff.importStrategy": "fromEnvironment", "ruff.organizeImports": true, "search.exclude": { "*/.pydocstyle": true, ".constraints/*.txt": true, "tests/**/__init__.py": true }, + "telemetry.telemetryLevel": "off", "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": "file:///home/redeboer/dev/redeboer/PawianTools/.github/workflows/requirements.yml" } diff --git a/README.md b/README.md index faa9205..a42b62a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen)](https://github.com/pre-commit/pre-commit) [![Prettier](https://camo.githubusercontent.com/687a8ae8d15f9409617d2cc5a30292a884f6813a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64655f7374796c652d70726574746965722d6666363962342e7376673f7374796c653d666c61742d737175617265)](https://prettier.io/) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) Go to [redeboer.github.io/PawianTools](https://redeboer.github.io/PawianTools) to view diff --git a/docs/conf.py b/docs/conf.py index 66a2379..3fed0ba 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,12 +15,14 @@ set_intersphinx_version_remapping, ) -set_intersphinx_version_remapping({ - "ipython": { - "8.12.2": "8.12.1", - "8.12.3": "8.12.1", - }, -}) +set_intersphinx_version_remapping( + { + "ipython": { + "8.12.2": "8.12.1", + "8.12.3": "8.12.1", + }, + } +) BRANCH = get_branch_name() ORGANIZATION = "redeboer" @@ -45,10 +47,12 @@ "members": True, "undoc-members": True, "show-inheritance": True, - "special-members": ", ".join([ - "__call__", - "__eq__", - ]), + "special-members": ", ".join( + [ + "__call__", + "__eq__", + ] + ), } autodoc_member_order = "bysource" autodoc_typehints_format = "short" diff --git a/environment.yml b/environment.yml index 0610a07..7c4effc 100644 --- a/environment.yml +++ b/environment.yml @@ -4,8 +4,8 @@ channels: dependencies: - graphviz # for binder - pip - - python==3.8.* + - python==3.9.* - pip: - - -c .constraints/py3.8.txt -e .[dev] + - -c .constraints/py3.9.txt -e .[dev] variables: PRETTIER_LEGACY_CLI: "1" diff --git a/pyproject.toml b/pyproject.toml index 21d5d58..6710377 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,17 +68,14 @@ doc = [ "sphinx-thebe", "sphinx-togglebutton", ] -format = [ - "black", -] jupyter = [ + "black", "isort", "jupyterlab", "jupyterlab-code-formatter", "jupyterlab-git", "jupyterlab-lsp", "jupyterlab-myst", - "jupyterlab-myst", "python-lsp-ruff", "python-lsp-server[rope]", ] @@ -93,8 +90,9 @@ lint = [ sty = [ "pawian-tools[format]", "pawian-tools[lint]", - "pawian-tools[test]", # for pytest type hints + "pawian-tools[test]", "pre-commit", + "ruff", ] test = [ "nbmake", @@ -128,31 +126,6 @@ where = ["src"] [tool.setuptools_scm] write_to = "src/pawian/version.py" -[tool.black] -exclude = ''' -/( - .*\.egg-info - | .*build - | \.eggs - | \.git - | \.pytest_cache - | \.tox - | \.venv - | \.vscode - | dist -)/ -''' -include = '\.pyi?$' -preview = true -target-version = [ - "py310", - "py311", - "py312", - "py37", - "py38", - "py39", -] - [tool.coverage.report] exclude_also = [ "if TYPE_CHECKING:", @@ -251,6 +224,19 @@ testpaths = [ [tool.ruff] extend-include = ["*.ipynb"] +preview = true +show-fixes = true +src = [ + "src", + "tests", +] +target-version = "py37" + +[tool.ruff.format] +docstring-code-format = true +line-ending = "lf" + +[tool.ruff.lint] extend-select = [ "A", "B", @@ -294,18 +280,17 @@ ignore = [ "D407", "D416", "E501", + "ISC001", + "PLW1514", "SIM108", "UP036", ] -show-fixes = true -src = [ - "src", - "tests", -] -target-version = "py37" task-tags = ["cspell"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.isort] +split-on-trailing-comma = false + +[tool.ruff.lint.per-file-ignores] "*.ipynb" = [ "B018", "C90", @@ -339,13 +324,15 @@ task-tags = ["cspell"] "D", "INP001", "PGH001", + "PLC2701", "PLR0913", "PLR2004", + "PLR6301", "S101", "T20", ] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" [tool.tomlsort] diff --git a/src/boostcfg/lineparser.py b/src/boostcfg/lineparser.py index 31a8681..caff38f 100644 --- a/src/boostcfg/lineparser.py +++ b/src/boostcfg/lineparser.py @@ -6,8 +6,8 @@ "get_key_value_pair", "is_commented", "is_empty", - "strip_comment", "string_to_value", + "strip_comment", ] diff --git a/tests/boostcfg/test_boostcfg.py b/tests/boostcfg/test_boostcfg.py index 2138657..bcd7a87 100644 --- a/tests/boostcfg/test_boostcfg.py +++ b/tests/boostcfg/test_boostcfg.py @@ -15,7 +15,7 @@ def test_append_value_from_line(): cfg.append_value_from_line("true_bool = true") assert cfg["key"] == "value" assert cfg["float"] == 3.14 - assert cfg["int"] == int(-11) + assert cfg["int"] == -11 assert not cfg["false_bool"] assert cfg["true_bool"] cfg.append_value_from_line("key = value")