fix some cython code

This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-03-29 21:18:18 +03:00
parent ad5530b9ef
commit 6269a7485c
32 changed files with 17108 additions and 2728 deletions
+5 -2
View File
@@ -1,6 +1,6 @@
---
description: "Python coding conventions: PEP 8, type hints, pydantic, pytest, async patterns, project structure"
globs: ["**/*.py", "**/pyproject.toml", "**/requirements*.txt"]
globs: ["**/*.py", "**/*.pyx", "**/*.pxd", "**/pyproject.toml", "**/requirements*.txt"]
---
# Python
@@ -12,5 +12,8 @@ globs: ["**/*.py", "**/pyproject.toml", "**/requirements*.txt"]
- Catch specific exceptions, never bare `except:`; use custom exception classes
- Use `async`/`await` with `asyncio` for I/O-bound concurrency
- Use `pytest` for testing (not `unittest`); fixtures for setup/teardown
- Use virtual environments (`venv` or `poetry`); pin dependencies
- **NEVER install packages globally** (`pip install` / `pip3 install` without a venv). ALWAYS use a virtual environment (`venv`, `poetry`, or `conda env`). If no venv exists for the project, create one first (`python3 -m venv .venv && source .venv/bin/activate`) before installing anything. Pin dependencies.
- Format with `black`; lint with `ruff` or `flake8`
## Cython
- In `cdef class` methods, prefer `cdef` over `cpdef` unless the method must be callable from Python. `cdef` = C-only (fastest), `cpdef` = C + Python, `def` = Python-only. Check all call sites before choosing.