Contributing¶
Thank you for your interest in tju!
Development setup¶
git clone https://github.com/tjuse/tju-python.git
cd tju-python
uv sync # installs runtime + dev deps into .venv
Running tests¶
The test suite is fully offline — no network access or credentials required.
30 tests across three modules:
| File | What it tests |
|---|---|
tests/test_parser.py |
Parser functions: raw HTML → dict/markdown |
tests/test_schema.py |
Model load/dump: parsed dict → typed dataclass → JSON |
tests/test_encrypt.py |
DES strEnc encryption |
Adding a feature¶
Follow the four-layer pipeline:
- Parser (
src/tju/parser/<feature>.py) — pure function:html: str → dict | list. No network I/O. Export it fromsrc/tju/parser/__init__.py. - Model (
src/tju/models/<feature>.py) —marshmallow-dataclassfrozen dataclass. Usemfield(data_key="中文字段名")to map Chinese column headers. Export fromsrc/tju/models/__init__.py. - Mixin (
src/tju/client/api/<feature>.py) —class XMixin(BaseClient)with one or more methods that orchestrate HTTP calls and call the parser + model. Export fromsrc/tju/client/api/__init__.pyand add to theClientbase-class list insrc/tju/client/__init__.py. - Tests + fixtures — add
tests/resources/website/<feature>.html(sanitised real HTML),tests/resources/parsed/parsed_<feature>.json, andtests/resources/serialised/<feature>.json, then add test functions intests/test_parser.pyandtests/test_schema.py.
Fixture privacy rule¶
Real personal data lives only in the gitignored .scratch/ directory.
Every committed fixture must be sanitised: replace real names, student IDs, national IDs,
photos, and grades with structurally-valid fake placeholders before adding to git.
Docstrings¶
Use a short, terse style (one-liner for simple functions, Google-style for complex ones). All public classes and functions should have at least a one-line docstring so that the MkDocs API reference is complete.
Building docs locally¶
Code style¶
There is currently no linting or type-checking configuration. Match the style of surrounding code: same comment density, naming, and idiom.