From 32876d3b258fbcf28da0d527bf8940fdcadd7f85 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Thu, 23 Nov 2023 22:46:23 -0800 Subject: [PATCH 1/5] replace black with ruff format --- .pre-commit-config.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 090cec973..006f44962 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,17 +24,14 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.3" + rev: "v3.1.0" hooks: - id: prettier types_or: [markdown, yaml] - - repo: https://github.com/psf/black - rev: "23.9.1" - hooks: - - id: black - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.292" + rev: "v0.1.6" hooks: - id: ruff + args: [--fix] + - id: ruff-format From 8b9929cbff82ac8c5f1f3f93a53cb81e2f8f07a5 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Thu, 23 Nov 2023 23:03:48 -0800 Subject: [PATCH 2/5] remove hatch, twine, and sphinx linkcheck from ci tests --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c5dd921c..e67de4357 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,13 +46,10 @@ jobs: - name: Lint code run: | SKIP=no-commit-to-branch pre-commit run --all-files - hatch build --clean - twine check --strict ./dist/* - name: Test docs run: | make -C ./docs html - python -m sphinx -b linkcheck docs/source build/linkcheck - name: Test code run: pytest --cov=./osmnx --cov-report=xml --cov-report=term-missing --verbose From a4a1d478adead240a149a494c8097db5aa9074a0 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Thu, 23 Nov 2023 23:05:30 -0800 Subject: [PATCH 3/5] replace black with ruff format --- environments/docker/requirements.txt | 1 - tests/environments/env-ci.yml | 1 - tests/environments/env-test-minimal.yml | 1 - tests/format.sh | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/environments/docker/requirements.txt b/environments/docker/requirements.txt index 4541a3c29..5cc85cbb0 100644 --- a/environments/docker/requirements.txt +++ b/environments/docker/requirements.txt @@ -31,7 +31,6 @@ pip twine # linting/testing -black nbdime nbqa pre-commit diff --git a/tests/environments/env-ci.yml b/tests/environments/env-ci.yml index 897c9c93c..fe2b9d12f 100644 --- a/tests/environments/env-ci.yml +++ b/tests/environments/env-ci.yml @@ -22,7 +22,6 @@ dependencies: - scipy # linting/testing - - black=23 - hatch - pre-commit - pytest diff --git a/tests/environments/env-test-minimal.yml b/tests/environments/env-test-minimal.yml index e050db23e..30ed6c4f2 100644 --- a/tests/environments/env-test-minimal.yml +++ b/tests/environments/env-test-minimal.yml @@ -25,7 +25,6 @@ dependencies: - scipy=1.5 # linting/testing - - black=23 - hatch - pre-commit - pytest diff --git a/tests/format.sh b/tests/format.sh index 7523b2535..628a86743 100644 --- a/tests/format.sh +++ b/tests/format.sh @@ -1,3 +1,3 @@ #!/bin/bash ruff check . --fix-only -black . +ruff format . From fb4c86bf379d9252c4ec9b8e36b735fefb48e274 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Thu, 23 Nov 2023 23:05:52 -0800 Subject: [PATCH 4/5] remove extra whitespace --- tests/packaging.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/packaging.sh b/tests/packaging.sh index 292ecb5b7..e7040a175 100644 --- a/tests/packaging.sh +++ b/tests/packaging.sh @@ -22,7 +22,7 @@ VERSION=$(hatch version) rm -rf ./dist hatch build --clean twine check --strict ./dist/* -SHA=$(openssl dgst -sha256 -r "./dist/$PACKAGE-$VERSION.tar.gz" | awk '{print $1}') +SHA=$(openssl dgst -sha256 -r "./dist/$PACKAGE-$VERSION.tar.gz" | awk '{print $1}') # rerender the conda-forge feedstock cd ../$PACKAGE-feedstock From 9524f12347bf8acab312f9b15f249ec916c0e9f4 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Thu, 23 Nov 2023 23:07:36 -0800 Subject: [PATCH 5/5] update ruff config --- pyproject.toml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 381140b91..65c45eb07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,11 +49,9 @@ visualization = ["matplotlib>=3.5"] [project.urls] Documentation = "https://osmnx.readthedocs.io" +Gallery = "https://github.com/gboeing/osmnx-examples" Repository = "https://github.com/gboeing/osmnx" -[tool.black] -line_length = 100 - [tool.hatch.build] packages = ["osmnx"] @@ -63,9 +61,12 @@ path = "osmnx/_version.py" [tool.ruff] cache-dir = "~/.cache/ruff" exclude = ["build/*"] -ignore = ["PLR091"] # ignore complexity checks (we check mccabe elsewhere) -line-length = 110 # black line length + 10% -select = [ +line-length = 100 +target-version = "py38" + +[tool.ruff.lint] +extend-ignore = ["PLR091"] # ignore PLR complexity checks (we check mccabe with C9) +extend-select = [ "A", # check python builtins being used as variables or parameters "ARG", # check unused function arguments "B", # check common design problems a la flake8-bugbear @@ -73,13 +74,13 @@ select = [ "C4", # check proper comprehensions "C9", # check mccabe complexity "D", # check docstring conventions a la pydocstyle + "D417", # check missing arguments in docstrings (disabled by default for numpy convention) "DTZ", # check unsafe naive datetime use a la flake8-datetimez "E", # check code style conventions a la pycodestyle errors "EM", # check raw literals inside exception raising "ERA", # check commented-out code from python files a la eradicate "F", # check python source code for errors a la pyflakes "I", # check isort imports - "ISC", # check implicit string literal concatenation "PERF", # check performance anti-patterns a la perflint "PGH", # check pygrep hooks "PIE", # check misc lints a la flake8-pie @@ -92,14 +93,19 @@ select = [ "UP", # check outdated syntax a la pyupgrade "W", # check code style conventions a la pycodestyle warnings ] -target-version = "py38" -[tool.ruff.isort] +[tool.ruff.lint.isort] force-single-line = true -[tool.ruff.mccabe] +[tool.ruff.lint.mccabe] max-complexity = 14 +[tool.ruff.lint.pycodestyle] +max-line-length = 110 # line length + 10% since it isn't a hard upper bound + +[tool.ruff.lint.pydocstyle] +convention = "numpy" + [tool.ruff.per-file-ignores] "./osmnx/_api.py" = ["F401"] # allow API imports to go unused "./tests/test_osmnx.py" = [ @@ -107,6 +113,3 @@ max-complexity = 14 "F841", # allow unused local variables "PLR2004", # allow magic values in comparisons ] - -[tool.ruff.pydocstyle] -convention = "numpy"