From 0c8a849b60b202f868ca7fb64df5d9b4d4147654 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 19 Aug 2024 02:10:45 +0200 Subject: [PATCH 1/5] chore: add toml formatter prettier pre-commit has been archived, but for now it seems to work --- .pre-commit-config.yaml | 6 +- pyproject.toml | 185 +++++++++++++++++++--------------------- 2 files changed, 93 insertions(+), 98 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e4d074845..c00641d4bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -63,10 +63,12 @@ repos: - id: ruff - id: ruff-format - repo: https://github.com/pre-commit/mirrors-prettier - rev: v4.0.0-alpha.8 + rev: v3.1.0 hooks: - id: prettier - types_or: [yaml, markdown, html, css, scss, javascript, json] + types_or: [yaml, markdown, html, css, scss, javascript, json, toml] + additional_dependencies: + - prettier-plugin-toml - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 1c5f6c103a..6568021a5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,57 +5,45 @@ name = "codespell" description = "Fix common misspellings in text files" readme = { file = "README.rst", content-type = "text/x-rst" } requires-python = ">=3.8" -license = {text = "GPL-2.0-only"} -authors = [ - {name = "Lucas De Marchi", email = "lucas.de.marchi@gmail.com"}, -] +license = { text = "GPL-2.0-only" } +authors = [{ name = "Lucas De Marchi", email = "lucas.de.marchi@gmail.com" }] classifiers = [ - "Intended Audience :: Developers", - "License :: OSI Approved", - "Programming Language :: Python", - "Topic :: Software Development", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", + "Intended Audience :: Developers", + "License :: OSI Approved", + "Programming Language :: Python", + "Topic :: Software Development", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] dependencies = [] dynamic = ["version"] [project.optional-dependencies] dev = [ - "build", - "chardet", - "pre-commit", - "pytest", - "pytest-cov", - "pytest-dependency", - "Pygments", - "ruff", - "tomli", - "twine" -] -hard-encoding-detection = [ - "chardet" -] -toml = [ - "tomli; python_version < '3.11'" -] -types = [ - "chardet>=5.1.0", - "mypy", - "pytest", - "pytest-cov", - "pytest-dependency", + "build", + "chardet", + "pre-commit", + "pytest", + "pytest-cov", + "pytest-dependency", + "Pygments", + "ruff", + "tomli", + "twine", ] +hard-encoding-detection = ["chardet"] +toml = ["tomli; python_version < '3.11'"] +types = ["chardet>=5.1.0", "mypy", "pytest", "pytest-cov", "pytest-dependency"] [project.scripts] codespell = "codespell_lib:_script_main" @@ -72,16 +60,13 @@ requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2, != 8.0.0"] write_to = "codespell_lib/_version.py" [tool.setuptools.packages.find] -exclude = [ - "dist", - "snap", -] +exclude = ["dist", "snap"] [tool.setuptools.package-data] codespell_lib = [ - "data/dictionary*.txt", - "data/linux-kernel.exclude", - "py.typed", + "data/dictionary*.txt", + "data/linux-kernel.exclude", + "py.typed", ] # TODO: reintegrate codespell configuration after updating test cases @@ -102,7 +87,15 @@ minversion = "6" testpaths = ["codespell_lib/tests"] log_cli_level = "INFO" xfail_strict = true -addopts = ["--cov=codespell_lib", "-rs", "--strict-config", "--strict-markers", "--cov-report=", "--tb=short", "--junit-xml=junit-results.xml"] +addopts = [ + "--cov=codespell_lib", + "-rs", + "--strict-config", + "--strict-markers", + "--cov-report=", + "--tb=short", + "--junit-xml=junit-results.xml", +] filterwarnings = ["error"] [tool.ruff] @@ -110,52 +103,52 @@ line-length = 88 [tool.ruff.lint] ignore = [ - "ANN101", - "B904", - "PLW2901", - "RET505", - "SIM105", - "SIM115", - # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules - "W191", - "E111", - "E114", - "E117", - "D206", - "D300", - "Q000", - "Q001", - "Q002", - "Q003", - "COM812", - "COM819", - "ISC001", - "ISC002", + "ANN101", + "B904", + "PLW2901", + "RET505", + "SIM105", + "SIM115", + # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules + "W191", + "E111", + "E114", + "E117", + "D206", + "D300", + "Q000", + "Q001", + "Q002", + "Q003", + "COM812", + "COM819", + "ISC001", + "ISC002", ] select = [ - "A", - "ANN", - "B", - "C40", - "C9", - "E", - "F", - "I", - "N", - "PLC", - "PLE", - "PLR", - "PT", - "PLW", - "RET", - "RUF", - "S", - "SIM", - "TRY", - "U", - "UP", - "W", - "YTT", + "A", + "ANN", + "B", + "C40", + "C9", + "E", + "F", + "I", + "N", + "PLC", + "PLE", + "PLR", + "PT", + "PLW", + "RET", + "RUF", + "S", + "SIM", + "TRY", + "U", + "UP", + "W", + "YTT", ] [tool.ruff.lint.mccabe] @@ -167,7 +160,7 @@ max-complexity = 45 "codespell_lib/tests/test_basic.py" = ["ANN401", "N802"] [tool.ruff.lint.pylint] -allow-magic-value-types = ["bytes", "int", "str",] +allow-magic-value-types = ["bytes", "int", "str"] max-args = 13 max-branches = 48 max-returns = 12 From 040ba7eeb9f7b9c01e3484b29a4446fc41c4f990 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 19 Aug 2024 02:29:14 +0200 Subject: [PATCH 2/5] Use taplo as formatter --- .pre-commit-config.yaml | 12 +-- pyproject.toml | 160 ++++++++++++++++++++-------------------- 2 files changed, 87 insertions(+), 85 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c00641d4bf..a5dd287cb8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,3 @@ ---- files: ^(.*\.(py|json|md|sh|yaml|yml|in|cfg|txt|rst|toml|precommit-toml|wordlist))$ exclude: ^(\.[^/]*cache/.*)$ repos: @@ -63,12 +62,10 @@ repos: - id: ruff - id: ruff-format - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 + rev: v4.0.0-alpha.8 hooks: - id: prettier - types_or: [yaml, markdown, html, css, scss, javascript, json, toml] - additional_dependencies: - - prettier-plugin-toml + types_or: [yaml, markdown, html, css, scss, javascript, json] - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: @@ -89,3 +86,8 @@ repos: - pytest - tomli - types-chardet + - repo: https://github.com/ComPWA/mirrors-taplo + rev: "v0.8.1" + hooks: + - id: taplo + entry: env RUST_LOG=warn taplo fmt --option indent_string=' ' diff --git a/pyproject.toml b/pyproject.toml index 6568021a5d..f746b1a720 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,38 +8,38 @@ requires-python = ">=3.8" license = { text = "GPL-2.0-only" } authors = [{ name = "Lucas De Marchi", email = "lucas.de.marchi@gmail.com" }] classifiers = [ - "Intended Audience :: Developers", - "License :: OSI Approved", - "Programming Language :: Python", - "Topic :: Software Development", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", + "Intended Audience :: Developers", + "License :: OSI Approved", + "Programming Language :: Python", + "Topic :: Software Development", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] dependencies = [] dynamic = ["version"] [project.optional-dependencies] dev = [ - "build", - "chardet", - "pre-commit", - "pytest", - "pytest-cov", - "pytest-dependency", - "Pygments", - "ruff", - "tomli", - "twine", + "build", + "chardet", + "pre-commit", + "pytest", + "pytest-cov", + "pytest-dependency", + "Pygments", + "ruff", + "tomli", + "twine", ] hard-encoding-detection = ["chardet"] toml = ["tomli; python_version < '3.11'"] @@ -64,9 +64,9 @@ exclude = ["dist", "snap"] [tool.setuptools.package-data] codespell_lib = [ - "data/dictionary*.txt", - "data/linux-kernel.exclude", - "py.typed", + "data/dictionary*.txt", + "data/linux-kernel.exclude", + "py.typed", ] # TODO: reintegrate codespell configuration after updating test cases @@ -88,13 +88,13 @@ testpaths = ["codespell_lib/tests"] log_cli_level = "INFO" xfail_strict = true addopts = [ - "--cov=codespell_lib", - "-rs", - "--strict-config", - "--strict-markers", - "--cov-report=", - "--tb=short", - "--junit-xml=junit-results.xml", + "--cov=codespell_lib", + "-rs", + "--strict-config", + "--strict-markers", + "--cov-report=", + "--tb=short", + "--junit-xml=junit-results.xml", ] filterwarnings = ["error"] @@ -103,52 +103,52 @@ line-length = 88 [tool.ruff.lint] ignore = [ - "ANN101", - "B904", - "PLW2901", - "RET505", - "SIM105", - "SIM115", - # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules - "W191", - "E111", - "E114", - "E117", - "D206", - "D300", - "Q000", - "Q001", - "Q002", - "Q003", - "COM812", - "COM819", - "ISC001", - "ISC002", + "ANN101", + "B904", + "PLW2901", + "RET505", + "SIM105", + "SIM115", + # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules + "W191", + "E111", + "E114", + "E117", + "D206", + "D300", + "Q000", + "Q001", + "Q002", + "Q003", + "COM812", + "COM819", + "ISC001", + "ISC002", ] select = [ - "A", - "ANN", - "B", - "C40", - "C9", - "E", - "F", - "I", - "N", - "PLC", - "PLE", - "PLR", - "PT", - "PLW", - "RET", - "RUF", - "S", - "SIM", - "TRY", - "U", - "UP", - "W", - "YTT", + "A", + "ANN", + "B", + "C40", + "C9", + "E", + "F", + "I", + "N", + "PLC", + "PLE", + "PLR", + "PT", + "PLW", + "RET", + "RUF", + "S", + "SIM", + "TRY", + "U", + "UP", + "W", + "YTT", ] [tool.ruff.lint.mccabe] From 27dd4a3238beb5eb9797e790bbcc6a49628ebf5e Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 19 Aug 2024 02:30:00 +0200 Subject: [PATCH 3/5] add back --- --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a5dd287cb8..14fa9e3feb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +--- files: ^(.*\.(py|json|md|sh|yaml|yml|in|cfg|txt|rst|toml|precommit-toml|wordlist))$ exclude: ^(\.[^/]*cache/.*)$ repos: From 793fe2ca079a9559aba793ff1a301c26bddd342e Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 19 Aug 2024 15:57:57 +0200 Subject: [PATCH 4/5] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 14fa9e3feb..0094d9ae72 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -88,7 +88,7 @@ repos: - tomli - types-chardet - repo: https://github.com/ComPWA/mirrors-taplo - rev: "v0.8.1" + rev: "v0.9.3" hooks: - id: taplo entry: env RUST_LOG=warn taplo fmt --option indent_string=' ' From f4d004352260a9801d5712e6f30af1383ca9bcff Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 19 Aug 2024 16:29:40 +0200 Subject: [PATCH 5/5] Update taplo --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0094d9ae72..7a387ac257 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -90,5 +90,5 @@ repos: - repo: https://github.com/ComPWA/mirrors-taplo rev: "v0.9.3" hooks: - - id: taplo + - id: taplo-format entry: env RUST_LOG=warn taplo fmt --option indent_string=' '