diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c4f94c9..a7802ef 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,6 @@ repos: - - - repo: 'https://github.com/ambv/black' - # 18.6b1 - rev: 22.3.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.10 hooks: - - id: black - args: ['--safe'] - - - repo: 'https://github.com/PyCQA/flake8' - rev: 5.0.4 - hooks: - - id: flake8 - args: [ - # E501 let black handle all line length decisions - # W503 black conflicts with "line break before operator" rule - # E203 black conflicts with "whitespace before ':'" rule - # E231 black conflicts with "whitespace after ':'" rule - # E722 bare excepts need to be addressed - '--ignore=E501,W503,E203,E722,E231'] + - id: ruff + - id: ruff-format diff --git a/CHANGELOG.md b/CHANGELOG.md index 33c15d9..084fd38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ======= +# 2.1.0 (2025-12-24) +- Replace black with ruff + # 2.0.0 (2025-12-23) - Migrates metadata to pyproject.toml - Drops support for Python versions < 3.10 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af4919c..7a31a4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,8 +3,10 @@ Hi there! Welcome to the tilesets-cli contributing document. Issues, comments, and pull requests are welcome. Please tag @mapbox/maps-api for any questions or reviews. ## Installation + First, clone the repo and `cd` into the folder: -```shell + +```bash # clone git clone git@github.com:mapbox/tilesets-cli.git cd tilesets-cli @@ -21,36 +23,14 @@ tilesets --version ``` ## Pre-commit hooks + We use [pre-commit hooks](https://pre-commit.com/) to auto-format and validate code before committing. `pre-commit` is included with the `[test]` extras, but you must run: -``` + +```bash $ pre-commit install ``` within the repo to have the actions specified in `.pre-commit-config.yaml` registered. -After this, when committing, you'll see: -``` -git commit -m 'update version' -black....................................................................Passed -Flake8...................................................................Passed -``` -If your pre-commit hooks ran successfully. Note that `black` modifies your code, which means that if there is a syntax error you'll first see something like: -``` -git commit -m '{message}' -black....................................................................Failed -hookid: black - -Files were modified by this hook. Additional output: - -reformatted this/file/was/reformatted.py -All done! ✨ 🍰 ✨ -1 file reformatted. - -Flake8...................................................................Failed -hookid: flake8 - -this/file/was/reformatted.py:{line}:{character}: {what was incorrect} -``` -After which you can add these changes and commit again. Note that failing pre-commit commands mean that the commit has not taken place: you must commit again! ## Release process diff --git a/mapbox_tilesets/errors.py b/mapbox_tilesets/errors.py index 523ec66..2fa7067 100644 --- a/mapbox_tilesets/errors.py +++ b/mapbox_tilesets/errors.py @@ -1,4 +1,5 @@ """Error handling for the tilesets CLI""" + from click import ClickException diff --git a/mapbox_tilesets/utils.py b/mapbox_tilesets/utils.py index 1181cff..8f8e2fa 100644 --- a/mapbox_tilesets/utils.py +++ b/mapbox_tilesets/utils.py @@ -83,7 +83,6 @@ def geojson_validate(index, feature): def validate_geojson(index, feature, allow_delete=False): - if allow_delete: delete_schema = { "definitions": {}, diff --git a/pyproject.toml b/pyproject.toml index 1b2c486..31de0f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "mapbox-tilesets" -version = "2.0.0" +version = "2.1.0" description = "CLI for interacting with and preparing data for the Mapbox Tilesets API" readme = "README.md" requires-python = ">=3.10" @@ -48,5 +48,13 @@ dev = [ "pytest-cov>=4", "build>=1.2", "pre-commit>=3.5", - "black==22.3.0", + "ruff>=0.14.10", +] + +[tool.ruff.lint] +ignore = [ + "E203", # whitespace before ':' + "E231", # missing whitespace after ',', ';', or ':' + "E501", # line too long + "E722" # bare except ]