|
31 | 31 | ## Code Quality |
32 | 32 |
|
33 | 33 | - Type hints required for all code |
34 | | -- Public APIs must have docstrings |
| 34 | +- Public APIs must have docstrings. When a public API raises exceptions a |
| 35 | + caller would reasonably catch, document them in a `Raises:` section. Don't |
| 36 | + list exceptions from argument validation or programmer error. |
35 | 37 | - `src/mcp/__init__.py` defines the public API surface via `__all__`. Adding a |
36 | 38 | symbol there is a deliberate API decision, not a convenience re-export. |
37 | 39 | - IMPORTANT: All imports go at the top of the file — inline imports hide |
|
50 | 52 | cleanest approach (see `tests/client/test_client.py` for the canonical |
51 | 53 | pattern). For narrower changes, testing the function directly is fine. Use |
52 | 54 | judgment. |
53 | | -- Test files mirror the source tree: `src/mcp/client/streamable_http.py` → |
54 | | - `tests/client/test_streamable_http.py`. Add tests to the existing file for that module. |
| 55 | +- Test files mirror the source tree: `src/mcp/client/stdio.py` → |
| 56 | + `tests/client/test_stdio.py`. Add tests to the existing file for that module. |
55 | 57 | - Avoid `anyio.sleep()` with a fixed duration to wait for async operations. Instead: |
56 | 58 | - Use `anyio.Event` — set it in the callback/handler, `await event.wait()` in the test |
57 | 59 | - For stream messages, use `await stream.receive()` instead of `sleep()` + `receive_nowait()` |
58 | 60 | - Exception: `sleep()` is appropriate when testing time-based features (e.g., timeouts) |
59 | 61 | - Wrap indefinite waits (`event.wait()`, `stream.receive()`) in `anyio.fail_after(5)` to prevent hangs |
60 | 62 | - Pytest is configured with `filterwarnings = ["error"]`, so warnings fail |
61 | | - tests. Don't silence them with `filterwarnings` or `warnings.catch_warnings()`; |
62 | | - fix the underlying cause instead. |
| 63 | + tests. Don't silence warnings from your own code; fix the underlying cause. |
| 64 | + Scoped `ignore::` entries for upstream libraries are acceptable in |
| 65 | + `pyproject.toml` with a comment explaining why. |
63 | 66 |
|
64 | 67 | ### Coverage |
65 | 68 |
|
|
0 commit comments