|
1 | | -## Quick orientation for AI coding agents |
| 1 | +# Quick orientation for AI coding agents |
2 | 2 |
|
3 | | -This repository is a hands-on, runnable "Ultimate Python" study guide composed of many small, standalone example modules under `ultimatepython/` grouped by topic (syntax, data_structures, classes, advanced). The goal for any change is to keep examples readable and runnable by humans and by the provided runner. |
4 | | - |
5 | | -Key facts an agent must know (short): |
| 3 | +## Key facts an agent must know (short): |
6 | 4 |
|
7 | 5 | - The runner: `runner.py` dynamically imports every module under `ultimatepython` and runs any callable named `main` with zero parameters. Keep `main()` functions parameterless, idempotent, and side-effect safe for CI. |
8 | 6 | - Single-file runs are supported: modules are runnable with `python ultimatepython/<category>/<module>.py`. Most modules already include `if __name__ == "__main__": main()`. |
9 | 7 | - Examples use plain Python stdlib only. Avoid adding new third-party dependencies without updating `requirements.txt` and `pyproject.toml`. |
10 | 8 | - Assertions are used as the primary verification mechanism inside examples (not pytest tests). Preserve their intent and messages when editing. |
11 | 9 |
|
12 | | -Patterns and conventions to follow |
| 10 | +## Patterns and conventions to follow |
13 | 11 |
|
14 | 12 | - main() contract: must be a function, accept zero parameters, and not raise exceptions when run. The runner asserts the function is callable and has zero parameters. Example: `ultimatepython/syntax/function.py` and `ultimatepython/classes/basic_class.py`. |
15 | 13 | - Module structure: brief module docstring, helper functions/classes, then `main()` demonstrating usage via asserts, and final `if __name__ == "__main__": main()`. |
16 | 14 | - Avoid long-running or destructive operations in examples. If a module interacts with the filesystem (e.g., `advanced/file_handling.py`), keep operations local to ephemeral files (module uses `_TARGET_FILE = "sample.txt"`), and clean up after running. |
17 | 15 | - Typing: some modules include simple type hints; prefer to keep existing style and minimal typing additions only. |
18 | 16 | - Formatting & linting: the repo uses `ruff` and `isort` settings in `pyproject.toml`. Try to keep line-length <= 160 and maintain import ordering consistent with isort defaults. |
19 | 17 |
|
20 | | -Developer workflows and useful commands |
| 18 | +## When creating or modifying modules |
| 19 | + |
| 20 | +- Preserve the didactic nature: keep explanatory comments and short, clear examples. |
| 21 | +- If you add new modules, include them under the appropriate folder and follow the same pattern (module docstring, helpers, `main()`, `if __name__...`). The runner will pick them up automatically. |
| 22 | +- If a change requires a new dependency, add it to `requirements.txt` and update `pyproject.toml` before proposing a PR. |
| 23 | + |
| 24 | +## Top-level README files |
| 25 | + |
| 26 | +- The top-level `README.md` is the primary project landing page: it explains the repo goals, running instructions, and links to example modules (it also shows badges for CI and coverage). When changing top-level documentation, keep the runner guidance intact (it points to `runner.py`) and preserve any badges and links. |
| 27 | +- Translated files like `README.ko.md`, `README.zh_tw.md`, `README.es.md`, `README.de.md`, `README.fr.md`, and `README.hi.md` are language variants of the same content. If you update the English `README.md`, consider updating translations or add a brief note in the PR explaining why translations were not updated. |
| 28 | + |
| 29 | +## Developer workflows and useful commands |
21 | 30 |
|
22 | 31 | - Run all examples locally (fast smoke): |
23 | 32 |
|
24 | | - python runner.py |
| 33 | +```bash |
| 34 | +python runner.py |
| 35 | +``` |
25 | 36 |
|
26 | 37 | - Run a single example (recommended when editing): |
27 | 38 |
|
28 | | - python ultimatepython/syntax/function.py |
| 39 | +```bash |
| 40 | +python ultimatepython/syntax/function.py |
| 41 | +``` |
29 | 42 |
|
30 | 43 | - Check formatting/linting (ruff/isort configured in `pyproject.toml`): run your local ruff/isort commands or CI. |
31 | 44 | - Coverage config exists in `pyproject.toml` (coverage fail_under=80). The examples use assertions; running `runner.py` is a good quick coverage smoke. |
32 | 45 |
|
33 | | -Integration points & CI notes |
| 46 | +## Integration points & CI notes |
34 | 47 |
|
35 | 48 | - CI expects that running `runner.py` and executing each `main()` will succeed. Avoid adding code that requires network access, long sleeps, or interactive input. |
36 | 49 | - Do not introduce external services or config files; this repo intentionally uses only the Python standard library. |
37 | 50 |
|
38 | | -When creating or modifying modules |
39 | | - |
40 | | -- Preserve the didactic nature: keep explanatory comments and short, clear examples. |
41 | | -- If you add new modules, include them under the appropriate folder and follow the same pattern (module docstring, helpers, `main()`, `if __name__...`). The runner will pick them up automatically. |
42 | | -- If a change requires a new dependency, add it to `requirements.txt` and update `pyproject.toml` before proposing a PR. |
43 | | - |
44 | | -Files and locations of interest (examples to inspect) |
| 51 | +## Files and locations of interest (examples to inspect) |
45 | 52 |
|
46 | 53 | - `runner.py` — how modules are discovered and executed (pkgutil.walk_packages + `main` lookups). |
47 | 54 | - `ultimatepython/syntax/*.py` — simple, illustrative examples of the `main()` pattern. |
|
0 commit comments