Skip to content

Commit

Permalink
Upgrade to Ruff. It's 2024, Charlie would be sad.
Browse files Browse the repository at this point in the history
  • Loading branch information
psobot committed Oct 8, 2024
1 parent b489833 commit 749d3ab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 31 deletions.
5 changes: 4 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ minimum-version = "0.4"
build-dir = "build/{wheel_tag}"

# Build stable ABI wheels for CPython 3.12+
wheel.py-api = "cp312"
wheel.py-api = "cp312"

[tool.ruff]
line-length = 120
2 changes: 1 addition & 1 deletion python/src/voyager/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .voyager_ext import *
from .voyager_ext import * # noqa: F403
14 changes: 7 additions & 7 deletions python/tests/test_load_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_v1_indices_must_have_no_parameters_or_must_match(load_from_stream: bool
(
b"VOYA" # Header
b"\x01\x00\x00\x00" # File version
b"\x0A\x00\x00\x00" # Number of dimensions (10)
b"\x0a\x00\x00\x00" # Number of dimensions (10)
b"\x00" # Space type
b"\x20"
+ struct.pack("f", 0) # Storage data type and maximum norm
Expand All @@ -153,7 +153,7 @@ def test_v1_indices_must_have_no_parameters_or_must_match(load_from_stream: bool
(
b"VOYA" # Header
b"\x01\x00\x00\x00" # File version
b"\x0A\x00\x00\x00" # Number of dimensions (10)
b"\x0a\x00\x00\x00" # Number of dimensions (10)
b"\x00" # Space type
b"\x20" # Storage data type
+ struct.pack("f", 0) # maximum norm
Expand All @@ -178,12 +178,12 @@ def test_v1_indices_must_have_no_parameters_or_must_match(load_from_stream: bool
(
b"VOYA" # Header
b"\x01\x00\x00\x00" # File version
b"\x0A\x00\x00\x00" # Number of dimensions (10)
b"\x0a\x00\x00\x00" # Number of dimensions (10)
b"\x00" # Space type
b"\x20" # Storage data type
+ struct.pack("f", 0) # maximum norm
+ b"\x00" # Use order-preserving transform
b"\x00\x00\x00\xFF\x00\x00\x00\x00" # offsetLevel0_
b"\x00\x00\x00\xff\x00\x00\x00\x00" # offsetLevel0_
b"\x01\x00\x00\x00\x00\x00\x00\x00" # max_elements_
b"\x01\x00\x00\x00\x00\x00\x00\x00" # cur_element_count
b"\x34\x00\x00\x00\x00\x00\x00\x00" # size_data_per_element_
Expand All @@ -203,7 +203,7 @@ def test_v1_indices_must_have_no_parameters_or_must_match(load_from_stream: bool
(
b"VOYA" # Header
b"\x01\x00\x00\x00" # File version
b"\x0A\x00\x00\x00" # Number of dimensions (10)
b"\x0a\x00\x00\x00" # Number of dimensions (10)
b"\x00" # Space type
b"\x20" # Storage data type
+ struct.pack("f", 0) # maximum norm
Expand All @@ -229,7 +229,7 @@ def test_v1_indices_must_have_no_parameters_or_must_match(load_from_stream: bool
(
b"VOYA" # Header
b"\x01\x00\x00\x00" # File version
b"\x0A\x00\x00\x00" # Number of dimensions (10)
b"\x0a\x00\x00\x00" # Number of dimensions (10)
b"\x00" # Space type
b"\x20" # Storage data type
+ struct.pack("f", 0) # maximum norm
Expand Down Expand Up @@ -284,7 +284,7 @@ def test_fuzz(seed: int, with_valid_header: bool, offset_level_0: int):
random_data.write(
b"VOYA" # Header
b"\x01\x00\x00\x00" # File version
b"\x0A\x00\x00\x00" # Number of dimensions (10)
b"\x0a\x00\x00\x00" # Number of dimensions (10)
b"\x00" # Space type
b"\x20" # Storage data type
)
Expand Down
28 changes: 6 additions & 22 deletions python/tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py,lint,check-formatting
envlist = py,check-formatting
skipsdist = True
usedevelop = True

Expand All @@ -15,33 +15,17 @@ commands =

[testenv:check-formatting]
basepython = python3
deps =
black
clang-format==14.0.6
deps = ruff
skip_install = true
commands =
black voyager tests --diff --check --line-length 120
commands = ruff check src/voyager tests --diff

[testenv:format]
basepython = python3
deps =
black
clang-format==14.0.6
deps = ruff
skip_install = true
commands =
black voyager tests --line-length 120

[testenv:lint]
basepython = python3
deps = flake8
skip_install = true
commands = flake8

[flake8]
show-source = true
max-line-length = 120
ignore = W503,E203
exclude = .venv,.tox,.git,dist,doc,*.egg,build
ruff format --diff src/voyager tests
ruff check --fix src/voyager tests

[pytest]
addopts =
Expand Down

0 comments on commit 749d3ab

Please sign in to comment.