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
Import order: stdlib β third-party β local (enforced by ruff/isort).
Prefer pathlib.Path over os.path.
3.3 Naming
Target
Convention
Example
Modules/packages
snake_case
local_store.py
Classes
PascalCase
SearchResult
Functions/methods/variables
snake_case
parse_query()
Constants
UPPER_SNAKE_CASE
MAX_RETRIES
Private members
Single underscore
_internal_state
3.4 Error Handling
Use specific exception types, not bare except:.
Log errors with structlog or stdlib logging β never print() in library code.
Network/IO failures must be retried with exponential backoff where appropriate.
3.5 Testing
Framework: pytest with pytest-asyncio for async tests.
Test files mirror source layout: infomesh/p2p/dht.py β tests/test_dht.py.
Each public function/method should have at least one test.
Use fixtures and factories over inline setup.
4. Dependencies & Package Management
Using uv
uv is used for all dependency resolution, virtual environments, and project management.
All dependencies declared in pyproject.toml under [project.dependencies].
Dev dependencies under [dependency-groups] (PEP 735) or [project.optional-dependencies.dev].
Pin minimum versions only (e.g., httpx>=0.27), not exact pins.
Lock file: uv.lock β committed to the repository for reproducible builds.
No requirements.txt, no pip β use uv commands only.
Key Commands
uv sync # Install all dependencies (creates .venv automatically)
uv sync --dev # Install with dev dependencies
uv add <package># Add a new dependency
uv add --dev <pkg># Add a dev dependency
uv run <command># Run a command within the project environment
uv run pytest # Run tests
uv run infomesh start # Run the application