Skip to content

Commit

Permalink
Merge pull request #1087 from gboeing/ruff
Browse files Browse the repository at this point in the history
update ruff config and replace black with ruff format
  • Loading branch information
gboeing authored Nov 27, 2023
2 parents 9aa78c5 + 9524f12 commit 9184066
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 28 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion environments/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pip
twine

# linting/testing
black
nbdime
nbqa
pre-commit
Expand Down
29 changes: 16 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -63,23 +61,26 @@ 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
"BLE", # check for blind exception catching
"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
Expand All @@ -92,21 +93,23 @@ 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" = [
"E402", # allow imports not at the top of the file
"F841", # allow unused local variables
"PLR2004", # allow magic values in comparisons
]

[tool.ruff.pydocstyle]
convention = "numpy"
1 change: 0 additions & 1 deletion tests/environments/env-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies:
- scipy

# linting/testing
- black=23
- hatch
- pre-commit
- pytest
Expand Down
1 change: 0 additions & 1 deletion tests/environments/env-test-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies:
- scipy=1.5

# linting/testing
- black=23
- hatch
- pre-commit
- pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/format.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
ruff check . --fix-only
black .
ruff format .
2 changes: 1 addition & 1 deletion tests/packaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9184066

Please sign in to comment.