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
**Types exist to help users and catch bugs—not to satisfy theoretical purity.**
77
+
78
+
This library uses type hinting to:
79
+
80
+
- Provide better IDE autocomplete and error detection
81
+
- Document expected types clearly
82
+
- Catch real errors before runtime
83
+
84
+
However, **pragmatism over pedantry**: if a typing pattern improves usability and robustness, use it—even if it technically violates some typing rule.
85
+
86
+
**Example:**`MACSBenchmark` narrows its environment type to `MACSEnvironment` (instead of generic `Environment`). This violates strict subtyping rules but provides users with:
87
+
88
+
- Precise autocomplete for MACS-specific methods
89
+
- Clear documentation that MACS requires its own environment
90
+
- Better error messages during development
91
+
- Prevents mixing incompatible components (e.g., `Tau2Environment` cannot be passed to `MACSBenchmark`)
92
+
93
+
Unless there's a graceful alternative that preserves usability, choose the pattern that helps users most.
94
+
95
+
**Guiding principle:** Orient yourself on existing patterns in the codebase. Consistency matters more than theoretical correctness.
96
+
97
+
### Syntax Rules
98
+
99
+
-**Unions:** Use `A | B` notation (not `Union[A, B]`)
100
+
-**Optional:** Prefer `Optional[X]` over `X | None` for explicitness
101
+
-**Collections:** Use `List[...]`, `Dict[..., ...]`, `Sequence[...]` instead of `list`, `dict`, `sequence`
102
+
103
+
**Example:**
104
+
105
+
```python
106
+
defprocess_data(
107
+
items: List[str],
108
+
config: Optional[Dict[str, Any]] =None
109
+
) -> str|int:
110
+
...
111
+
```
112
+
58
113
## Dependency Management
59
114
60
115
Three types of dependencies:
@@ -220,7 +275,7 @@ Example workflow:
220
275
uv sync --all-extras --all-groups
221
276
222
277
# Before committing
223
-
uv run ruff format .&& uv run ruff check . --fix && uv run pytest -v
278
+
uv run ruff format .&& uv run ruff check . --fix && uv run pytest -v&& uv run ty check
0 commit comments