diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 821aaa5b5..c24f42564 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -60,7 +60,7 @@ jobs: cache: poetry - name: Install dependencies - run: poetry install --only=format + run: poetry install --only=lint - name: Check code formatting # the job output will contain colored diffs with what needs adjusting diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a41758897..477cf9cc0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,13 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - - repo: https://github.com/psf/black - rev: 24.2.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.6 hooks: - - id: black - - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - name: isort (python) + - id: ruff-format diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index e54076ba0..911090f17 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -274,14 +274,13 @@ There are a few coding conventions we use in beets: Style ----- -We follow `black`_ formatting and `google's docstring format`_. +We use `ruff`_ to format and lint the codebase. -Use ``poe check-format`` and ``poe lint`` to check your code for style and +Run ``poe check-format`` and ``poe lint`` to check your code for style and linting errors. Running ``poe format`` will automatically format your code according to the specifications required by the project. -.. _black: https://black.readthedocs.io/en/stable/ -.. _google's docstring format: https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings +.. _ruff: https://docs.astral.sh/ruff/ Handling Paths -------------- diff --git a/poetry.lock b/poetry.lock index b7e46d71e..bca5609d9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -110,52 +110,6 @@ charset-normalizer = ["charset-normalizer"] html5lib = ["html5lib"] lxml = ["lxml"] -[[package]] -name = "black" -version = "24.8.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-24.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:09cdeb74d494ec023ded657f7092ba518e8cf78fa8386155e4a03fdcc44679e6"}, - {file = "black-24.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:81c6742da39f33b08e791da38410f32e27d632260e599df7245cccee2064afeb"}, - {file = "black-24.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:707a1ca89221bc8a1a64fb5e15ef39cd755633daa672a9db7498d1c19de66a42"}, - {file = "black-24.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:d6417535d99c37cee4091a2f24eb2b6d5ec42b144d50f1f2e436d9fe1916fe1a"}, - {file = "black-24.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:fb6e2c0b86bbd43dee042e48059c9ad7830abd5c94b0bc518c0eeec57c3eddc1"}, - {file = "black-24.8.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:837fd281f1908d0076844bc2b801ad2d369c78c45cf800cad7b61686051041af"}, - {file = "black-24.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:62e8730977f0b77998029da7971fa896ceefa2c4c4933fcd593fa599ecbf97a4"}, - {file = "black-24.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:72901b4913cbac8972ad911dc4098d5753704d1f3c56e44ae8dce99eecb0e3af"}, - {file = "black-24.8.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:7c046c1d1eeb7aea9335da62472481d3bbf3fd986e093cffd35f4385c94ae368"}, - {file = "black-24.8.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:649f6d84ccbae73ab767e206772cc2d7a393a001070a4c814a546afd0d423aed"}, - {file = "black-24.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2b59b250fdba5f9a9cd9d0ece6e6d993d91ce877d121d161e4698af3eb9c1018"}, - {file = "black-24.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:6e55d30d44bed36593c3163b9bc63bf58b3b30e4611e4d88a0c3c239930ed5b2"}, - {file = "black-24.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:505289f17ceda596658ae81b61ebbe2d9b25aa78067035184ed0a9d855d18afd"}, - {file = "black-24.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b19c9ad992c7883ad84c9b22aaa73562a16b819c1d8db7a1a1a49fb7ec13c7d2"}, - {file = "black-24.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1f13f7f386f86f8121d76599114bb8c17b69d962137fc70efe56137727c7047e"}, - {file = "black-24.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:f490dbd59680d809ca31efdae20e634f3fae27fba3ce0ba3208333b713bc3920"}, - {file = "black-24.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:eab4dd44ce80dea27dc69db40dab62d4ca96112f87996bca68cd75639aeb2e4c"}, - {file = "black-24.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3c4285573d4897a7610054af5a890bde7c65cb466040c5f0c8b732812d7f0e5e"}, - {file = "black-24.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9e84e33b37be070ba135176c123ae52a51f82306def9f7d063ee302ecab2cf47"}, - {file = "black-24.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:73bbf84ed136e45d451a260c6b73ed674652f90a2b3211d6a35e78054563a9bb"}, - {file = "black-24.8.0-py3-none-any.whl", hash = "sha256:972085c618ee94f402da1af548a4f218c754ea7e5dc70acb168bfaca4c2542ed"}, - {file = "black-24.8.0.tar.gz", hash = "sha256:2500945420b6784c38b9ee885af039f5e7471ef284ab03fa35ecdde4688cd83f"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "blinker" version = "1.8.2" @@ -924,23 +878,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "isort" -version = "5.13.2" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, - {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, -] - -[package.dependencies] -colorama = {version = ">=0.4.6", optional = true, markers = "extra == \"colors\""} - -[package.extras] -colors = ["colorama (>=0.4.6)"] - [[package]] name = "itsdangerous" version = "2.2.0" @@ -1687,17 +1624,6 @@ files = [ {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] -[[package]] -name = "pathspec" -version = "0.12.1" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.8" -files = [ - {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, - {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, -] - [[package]] name = "pillow" version = "10.4.0" @@ -3206,4 +3132,4 @@ web = ["flask", "flask-cors"] [metadata] lock-version = "2.0" python-versions = ">=3.8,<4" -content-hash = "40aa1c95a4d1f17e50ce3514f729b104ec9a3bd61ed164a2f937613cb9ed2330" +content-hash = "b3eb66c6852cb14afcbe817619ea9ecea699e838885d8e9719f2809eb708bcc3" diff --git a/pyproject.toml b/pyproject.toml index 69f4bf70a..9f8552261 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,10 +84,6 @@ rarfile = "*" requests_oauthlib = "*" responses = ">=0.3.0" -[tool.poetry.group.format.dependencies] -isort = { version = "<5.14", extras = ["colors"] } -black = ">=24.3,<25" - [tool.poetry.group.lint.dependencies] ruff = ">=0.6.4" @@ -153,24 +149,6 @@ build-backend = "poetry.core.masonry.api" poethepoet = ">=0.26" poetry = ">=1.8" -# We use a default path '.' to make black and isort behave like ruff and -# mypy do: they act on the entire codebase (ruff does it by default, and -# mypy follows our configuration) by default. Positional command-line arguments -# override this. Therefore, locally you can run `poe check-format ` -# to quickly check a specific path. -# -# Note: both tools respect .gitignore, therefore if we see them format -# something unwanted locally, we should add these paths to .gitignore. -[tool.poe.tasks._black] -help = "Run black" -cmd = "black $OPTS $path" -args = { path = { help = "Path to blacken", positional = true, multiple = true, default = "." } } - -[tool.poe.tasks._isort] -help = "Run isort" -cmd = "isort $OPTS $path" -args = { path = { help = "Path to isort", positional = true, multiple = true, default = "." } } - [tool.poe.tasks.bump] help = "Bump project version and update relevant files" cmd = "python ./extra/release.py bump $version" @@ -186,8 +164,7 @@ cmd = "make -C docs linkcheck" [tool.poe.tasks.check-format] help = "Check the code for style issues" -ref = "format" -env.OPTS = "--check --diff --color" +cmd = "ruff format --check --diff" [tool.poe.tasks.check-types] help = "Check the code for typing issues. Accepts mypy options." @@ -199,9 +176,7 @@ cmd = "make -C docs html" [tool.poe.tasks.format] help = "Format the codebase" -ignore_fail = "return_non_zero" -sequence = ["_black $path", "_isort $path"] -args = { path = { help = "Path to format", positional = true, multiple = true, default = "." } } +cmd = "ruff format" [tool.poe.tasks.lint] help = "Check the code for linting issues. Accepts ruff options." @@ -248,17 +223,6 @@ done """ interpreter = "zsh" -[tool.black] -line-length = 80 -target-version = ["py38", "py39", "py310", "py311"] - -[tool.isort] -profile = "black" -py_version = 38 -multi_line_output = 3 -line_length = 80 -indent = 4 - [tool.ruff] target-version = "py38" line-length = 80