You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is built on top of [CocoIndex v1](https://cocoindex.io/docs-v1/llms.txt).
2
+
3
+
4
+
## Build and Test Commands
5
+
6
+
This project uses [uv](https://docs.astral.sh/uv/) for project management.
7
+
8
+
```bash
9
+
uv run mypy .# Type check Python code
10
+
uv run pytest tests/ # Run Python tests
11
+
```
12
+
13
+
## Code Conventions
14
+
15
+
### Internal vs External Modules
16
+
17
+
We distinguish between **internal modules** (under packages with `_` prefix, e.g. `_internal.*` or `connectors.*._source`) and **external modules** (which users can directly import).
18
+
19
+
**External modules** (user-facing, e.g. `cocoindex/ops/sentence_transformers.py`):
20
+
21
+
* Be strict about not leaking implementation details
22
+
* Use `__all__` to explicitly list public exports
23
+
* Prefix ALL non-public symbols with `_`, including:
24
+
* Standard library imports: `import threading as _threading`, `import typing as _typing`
25
+
* Third-party imports: `import numpy as _np`, `from numpy.typing import NDArray as _NDArray`
26
+
* Internal package imports: `from cocoindex.resources import schema as _schema`
27
+
* Exception: `TYPE_CHECKING` imports for type hints don't need prefixing
* Less strict since users shouldn't import these directly
32
+
* Standard library and internal imports don't need underscore prefix
33
+
* Only prefix symbols that are truly private to the module itself (e.g. `_context_var` for a module-private ContextVar)
34
+
35
+
### General principles (also covered by `/review-changes`)
36
+
37
+
-**Top-level imports.** Defer to in-function only for a real circular dependency or a heavy import that isn't always needed.
38
+
-**Specific types over `Any`.** When a value enters as a weaker form (`str`, `Any`), convert to the strong type at the earliest point. Don't propagate the weak form.
39
+
-**`NamedTuple`/small dataclass for multi-value returns.** Access fields by name at call sites.
40
+
-**Single source of truth.** When the same value or logic appears in multiple places, consolidate it.
41
+
-**Delete dead code and dead config.** When a change makes something unreachable, the code, the tests, and the knobs all go.
42
+
-**Honest names.** The name describes what the code does today.
43
+
44
+
### Testing Guidelines
45
+
46
+
We prefer end-to-end tests on user-facing APIs, over unit tests on smaller internal functions. With this said, there're cases where unit tests are necessary, e.g. for internal logic with various situations and edge cases, in which case it's usually easier to cover various scenarios with unit tests.
47
+
48
+
When tests fail, fix the underlying issue. Don't skip, ignore, or exclude to get a green result.
0 commit comments