Skip to content

Commit 09fabf5

Browse files
523034406523034406
authored andcommitted
docs: add code style guide
1 parent 95b5728 commit 09fabf5

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

CODE_STYLE.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# SoloFlow Code Style Guide
2+
3+
## Python Style
4+
5+
### General
6+
- Follow PEP 8
7+
- Use type hints for all functions
8+
- Use docstrings for all public functions
9+
- Keep functions focused and small
10+
- Use meaningful variable names
11+
12+
### Imports
13+
```python
14+
# Good
15+
from typing import Optional, List
16+
from pathlib import Path
17+
18+
# Bad
19+
from typing import *
20+
import os, sys
21+
```
22+
23+
### Type Hints
24+
```python
25+
# Good
26+
def process(data: dict[str, Any]) -> list[str]:
27+
...
28+
29+
# Bad
30+
def process(data):
31+
...
32+
```
33+
34+
### Docstrings
35+
```python
36+
# Good
37+
def calculate_retention(time_elapsed: float, stability: float) -> float:
38+
"""Calculate memory retention using Ebbinghaus curve.
39+
40+
Args:
41+
time_elapsed: Time in seconds since last access
42+
stability: Memory stability factor
43+
44+
Returns:
45+
Retention value between 0.0 and 1.0
46+
"""
47+
...
48+
49+
# Bad
50+
def calculate_retention(t, s):
51+
# Calculate retention
52+
...
53+
```
54+
55+
## Testing Style
56+
57+
### Test Naming
58+
```python
59+
# Good
60+
def test_create_workflow_with_valid_steps():
61+
...
62+
63+
def test_create_workflow_with_empty_steps_raises_error():
64+
...
65+
66+
# Bad
67+
def test_workflow():
68+
...
69+
```
70+
71+
### Test Structure
72+
```python
73+
# Arrange
74+
store = SQLiteStore(db_path)
75+
store.initialize()
76+
service = WorkflowService(store)
77+
78+
# Act
79+
result = await service.create_workflow(...)
80+
81+
# Assert
82+
assert result["state"] == "draft"
83+
```
84+
85+
## Documentation Style
86+
87+
### README
88+
- Clear project description
89+
- Quick start guide
90+
- API reference
91+
- Examples
92+
93+
### Code Comments
94+
- Explain why, not what
95+
- Keep comments up to date
96+
- Remove commented-out code

0 commit comments

Comments
 (0)