Skip to content

Commit 36755b3

Browse files
authored
Merge pull request #2848 from mabel-dev/copilot/create-fast-json-lines-decoder
Implement fast JSONL decoder with Cython-based value extraction
2 parents 5b8f4b8 + 67044fb commit 36755b3

File tree

10 files changed

+681
-8
lines changed

10 files changed

+681
-8
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ help: ## Show this help message
5151
lint: ## Run all linting tools
5252
$(call print_blue,"Installing linting tools...")
5353
@$(PIP) install --quiet --upgrade pycln isort ruff yamllint cython-lint
54+
$(call print_blue,"Removing whitespace in pyx files...")
55+
@$(PYTHON) dev/fix_cython_whitespace.py
5456
$(call print_blue,"Running Cython lint...")
5557
@cython-lint $(SRC_DIR)/compiled/**/*.pyx || true
5658
$(call print_blue,"Running Ruff checks...")

dev/fix_cython_whitespace.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Fix whitespace issues in Cython files.
4+
Removes trailing whitespace from blank lines (W293 errors).
5+
"""
6+
from pathlib import Path
7+
8+
9+
def fix_whitespace_in_file(filepath: Path) -> bool:
10+
"""
11+
Fix whitespace issues in a single file.
12+
13+
Returns:
14+
bool: True if file was modified, False otherwise
15+
"""
16+
try:
17+
with open(filepath, 'r', encoding='utf-8') as f:
18+
original_content = f.read()
19+
20+
# Remove trailing whitespace from all lines
21+
# This fixes W293 (blank line contains whitespace) and similar issues
22+
lines = original_content.splitlines(keepends=True)
23+
fixed_lines = [line.rstrip() + ('\n' if line.endswith('\n') else '') for line in lines]
24+
fixed_content = ''.join(fixed_lines)
25+
26+
# Remove trailing newline at end of file if present
27+
fixed_content = fixed_content.rstrip() + '\n'
28+
29+
if fixed_content != original_content:
30+
with open(filepath, 'w', encoding='utf-8') as f:
31+
f.write(fixed_content)
32+
return True
33+
return False
34+
except (OSError, UnicodeDecodeError) as e:
35+
print(f"Error processing {filepath}: {e}")
36+
return False
37+
38+
39+
def main():
40+
"""Fix whitespace in all Cython files."""
41+
root = Path(__file__).parent.parent
42+
print(f"Scanning for .pyx files in {root}")
43+
pyx_files = list(root.rglob('opteryx/**/*.pyx'))
44+
45+
if not pyx_files:
46+
print("No .pyx files found")
47+
return
48+
49+
print(f"Found {len(pyx_files)} .pyx files")
50+
modified_count = 0
51+
52+
for filepath in sorted(pyx_files):
53+
if fix_whitespace_in_file(filepath):
54+
print(f"Fixed: {filepath.relative_to(root)}")
55+
modified_count += 1
56+
57+
print(f"\nFixed {modified_count} file(s)")
58+
59+
60+
if __name__ == '__main__':
61+
main()

opteryx/__version__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# THIS FILE IS AUTOMATICALLY UPDATED DURING THE BUILD PROCESS
22
# DO NOT EDIT THIS FILE DIRECTLY
33

4-
__build__ = 1654
4+
__build__ = 1657
55
__author__ = "@joocer"
6-
__version__ = "0.26.0-beta.1654"
6+
__version__ = "0.26.0-beta.1657"
77

88
# Store the version here so:
99
# 1) we don't load dependencies by storing it in __init__.py

0 commit comments

Comments
 (0)