ilc-models 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. ilc_models-0.3.2/.vscode/settings.json +3 -0
  2. {ilc_models-0.3.0 → ilc_models-0.3.2}/CHANGELOG.md +28 -1
  3. {ilc_models-0.3.0 → ilc_models-0.3.2}/CLAUDE.md +24 -8
  4. {ilc_models-0.3.0 → ilc_models-0.3.2}/PKG-INFO +24 -9
  5. {ilc_models-0.3.0 → ilc_models-0.3.2}/README.md +22 -8
  6. {ilc_models-0.3.0 → ilc_models-0.3.2}/docs/requirements.txt +14 -13
  7. ilc_models-0.3.2/docs/source/api.rst +59 -0
  8. {ilc_models-0.3.0 → ilc_models-0.3.2}/docs/source/conf.py +1 -1
  9. {ilc_models-0.3.0 → ilc_models-0.3.2}/docs/source/usage.rst +27 -6
  10. {ilc_models-0.3.0 → ilc_models-0.3.2}/pyproject.toml +12 -6
  11. ilc_models-0.3.2/src/ilc_models/__init__.py +57 -0
  12. ilc_models-0.3.2/src/ilc_models/event.py +200 -0
  13. ilc_models-0.3.2/src/ilc_models/league.py +459 -0
  14. ilc_models-0.3.2/src/ilc_models/lineup.py +102 -0
  15. ilc_models-0.3.2/src/ilc_models/match.py +362 -0
  16. ilc_models-0.3.2/src/ilc_models/player.py +121 -0
  17. ilc_models-0.3.2/src/ilc_models/table.py +280 -0
  18. ilc_models-0.3.2/src/ilc_models/user.py +207 -0
  19. ilc_models-0.3.2/tests/test_event.py +75 -0
  20. ilc_models-0.3.2/tests/test_init.py +35 -0
  21. ilc_models-0.3.2/tests/test_league.py +409 -0
  22. ilc_models-0.3.2/tests/test_lineup.py +74 -0
  23. ilc_models-0.3.2/tests/test_match.py +349 -0
  24. ilc_models-0.3.2/tests/test_player.py +95 -0
  25. ilc_models-0.3.2/tests/test_table.py +123 -0
  26. ilc_models-0.3.2/tests/test_user.py +242 -0
  27. ilc_models-0.3.2/uv.lock +1226 -0
  28. ilc_models-0.3.0/docs/source/api.rst +0 -6
  29. ilc_models-0.3.0/src/ilc_models/__init__.py +0 -1600
  30. ilc_models-0.3.0/tests/test_models.py +0 -1182
  31. ilc_models-0.3.0/uv.lock +0 -1168
  32. {ilc_models-0.3.0 → ilc_models-0.3.2}/.claude/settings.local.json +0 -0
  33. {ilc_models-0.3.0 → ilc_models-0.3.2}/.gitignore +0 -0
  34. {ilc_models-0.3.0 → ilc_models-0.3.2}/.python-version +0 -0
  35. {ilc_models-0.3.0 → ilc_models-0.3.2}/.readthedocs.yaml +0 -0
  36. {ilc_models-0.3.0 → ilc_models-0.3.2}/LICENSE.txt +0 -0
  37. {ilc_models-0.3.0 → ilc_models-0.3.2}/docs/source/_static/.gitkeep +0 -0
  38. {ilc_models-0.3.0 → ilc_models-0.3.2}/docs/source/index.rst +0 -0
  39. {ilc_models-0.3.0 → ilc_models-0.3.2}/justfile +0 -0
  40. {ilc_models-0.3.0 → ilc_models-0.3.2}/src/ilc_models/py.typed +0 -0
  41. {ilc_models-0.3.0 → ilc_models-0.3.2}/tests/__init__.py +0 -0
  42. {ilc_models-0.3.0 → ilc_models-0.3.2}/tests/conftest.py +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
3
+ }
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.2] - 2026-11-26
4
+
5
+ ### Added
6
+
7
+ - Add `created_at` field to `UserPublic`, and so to `User`: an offset-aware UTC `datetime`, default `None`; naive values are treated as UTC and aware ones converted to UTC
8
+ - `User.create()` sets `created_at` to the current UTC time
9
+ - Add `teams` field (favourite teams, default `[]`) to `UserPublic`, and so to `User`; names are stripped, empty names dropped and duplicates removed
10
+ - Add `teams` parameter to `User.create()`
11
+ - Add `validate_created_at()` and `validate_teams()` validators
12
+ - Add an explicit `__all__` listing every public name
13
+ - Support Python 3.15
14
+
15
+ ### Changed
16
+
17
+ - Split the package into submodules by domain (`player`, `lineup`, `event`, `match`, `table`, `league`, `user`); every public name is still importable from `ilc_models`
18
+
19
+ ## [0.3.1] - 2026-10-25
20
+
21
+ ### Added
22
+
23
+ - Add required `username` and `status` (`"pending"` or `"active"`, default `"pending"`) fields to `UserPublic`, and so to `User`
24
+ - Add `username` and `status` parameters to `User.create()`; `username` defaults to the part of the email address before the `@`
25
+
3
26
  ## [0.3.0] - 2026-10-19
4
27
 
5
28
  ### Added
@@ -124,7 +147,11 @@
124
147
 
125
148
  _Initial release._
126
149
 
127
- [Unreleased]: https://github.com/fourtreestech/ilc-models/compare/v0.2.4...HEAD
150
+ [0.3.2]: https://github.com/fourtreestech/ilc-models/releases/tag/v0.3.2
151
+
152
+ [0.3.1]: https://github.com/fourtreestech/ilc-models/releases/tag/v0.3.1
153
+
154
+ [0.3.0]: https://github.com/fourtreestech/ilc-models/releases/tag/v0.3.0
128
155
 
129
156
  [0.2.4]: https://github.com/fourtreestech/ilc-models/releases/tag/v0.2.4
130
157
 
@@ -22,10 +22,10 @@ just publish # rm -rf dist, uv build, then uv publish to PyPI
22
22
  Single test / narrower runs:
23
23
 
24
24
  ```sh
25
- uv run pytest tests/test_models.py::TestLeagueTable
26
- uv run pytest tests/test_models.py::TestMatch::test_players_from_team
25
+ uv run pytest tests/test_league.py::TestLeagueTable
26
+ uv run pytest tests/test_match.py::TestMatch::test_players_from_team
27
27
  uv run pytest -p no:randomly # pytest-randomly shuffles order; disable when bisecting a failure
28
- uvx tox # full matrix: Python 3.12, 3.13, 3.14 (pinned to `uv.lock`), plus `lowest` (3.12 with the lowest dependency versions, including transitive ones) and `highest` (3.14 with the newest releases, ignoring `uv.lock`)
28
+ uvx tox # full matrix: Python 3.12, 3.13, 3.14, 3.15 (pinned to `uv.lock`), plus `lowest` (3.12 with `--resolution lowest-direct`: lowest versions of direct dependencies only, transitive ones resolve to newest) and `highest` (3.15 with the newest releases, ignoring `uv.lock`)
29
29
  ```
30
30
 
31
31
  There is no `[tool.pytest.ini_options]` section — pytest runs on defaults with `tests/` discovered from the repo root.
@@ -40,9 +40,25 @@ The version string lives in **four** places, kept in sync by bumpver (`[tool.bum
40
40
 
41
41
  ## Architecture
42
42
 
43
- Everything is one module: `src/ilc_models/__init__.py`. Pydantic v2 models with no I/O — this package is the data contract shared across the ILC repos, so a field change here is a breaking change for `ilc-api`, `ilc-app`, and `ilc-admin`. Its only dependencies are `pydantic[email]` (for `EmailStr`) and `argon2-cffi`, which `User` uses for password hashing through the private module-level `_ph` hasher; don't add any others.
43
+ The package is split into submodules by domain under `src/ilc_models/`:
44
44
 
45
- `User` is the stored shape (Mongo), including `password_hash`, so `model_dump()` includes it. `UserPublic` is the API response shape with no secrets, and `User` subclasses it. Fields that must never leave the API go on `User` only; `ilc-api` should declare `response_model=UserPublic`.
45
+ | Module | Contents |
46
+ |---|---|
47
+ | `player.py` | `BasePlayer`, `Player`, `validate_dob` |
48
+ | `lineup.py` | `Lineup`, `Lineups` |
49
+ | `event.py` | `EventTime`, `BaseEvent`, `Goal`, `Card`, `Substitution`, `LineupStatus`, the `Event` union |
50
+ | `match.py` | `Teams`, `Score`, `Match`, `EventInfo`, `validate_kickoff` |
51
+ | `table.py` | `RowTuple`, `TableRow`, `Deduction`, `validate_deduction_date` |
52
+ | `league.py` | `League`, `validate_date` |
53
+ | `user.py` | `UserPublic`, `User`, `validate_created_at`, `validate_teams`, and the private `_ph` / `_hash_password` |
54
+
55
+ Imports between submodules only flow one way (`player` → `lineup`/`event` → `match` → `table` → `league`; `user` is standalone), so keep them that way to avoid cycles. Pydantic resolves field annotations at runtime, so cross-module model imports must be real imports, not `TYPE_CHECKING`-only.
56
+
57
+ `__init__.py` holds `__version__` and re-exports every public name, with an explicit `__all__`. Every consumer imports from the top level (`from ilc_models import League`), never from a submodule, so the submodule layout is internal. **A new public name must be imported into `__init__.py` and added to `__all__`**; `tests/test_init.py` fails if a public class or function defined in a submodule is missing from `__all__`.
58
+
59
+ These are Pydantic v2 models with no I/O — this package is the data contract shared across the ILC repos, so a field change here is a breaking change for `ilc-api`, `ilc-app`, and `ilc-admin`. Its only dependencies are `pydantic[email]` (for `EmailStr`) and `argon2-cffi`, which `User` uses for password hashing through the private module-level `_ph` hasher in `user.py`; don't add any others.
60
+
61
+ `User` is the stored shape (Mongo), including `password_hash`, so `model_dump()` includes it. `UserPublic` is the API response shape with no secrets, and `User` subclasses it. Fields that must never leave the API go on `User` only; `ilc-api` should declare `response_model=UserPublic`. Request bodies in `ilc-api` use their own schemas and never `UserPublic`/`User`, so server-set fields such as `created_at` can't come from clients; keep it that way.
46
62
 
47
63
  `User.verify_password()` never modifies the user. To upgrade outdated hashes, the caller does `if user.verify_password(attempt) and user.needs_rehash(): user.set_password(attempt)` and then persists the user.
48
64
 
@@ -58,7 +74,7 @@ Containment: `League` → `rounds: dict[str, list[Match]]` → `Match` → `Line
58
74
 
59
75
  **`League.table()` models the Scottish-style split.** Once any team has played more than `League.split` matches, the table freezes the top/bottom halves by position at the split point — computed by recursing into `self.table(split_point=True)` — and sorts each half independently. An odd team count puts the extra team in the top half. Points deductions apply only when `Deduction.date` is empty (season-start) or falls on/before the last match processed, which is why the loop tracks `last_date`.
60
76
 
61
- **Dates are validated ISO strings, not `date` objects.** `Match.kickoff` requires a full offset-aware timestamp (strict `Field(pattern=...)`), `League.start`/`end` require `yyyy-mm-dd`. Four `WrapValidator` helpers layer a real-calendar check (via `datetime.date`/`datetime.datetime`) on top of each field's regex, so month 19 or 29 February in a non-leap year raises `ValueError` rather than validating: `validate_dob` and `validate_deduction_date` additionally accept the empty string, and `validate_dob` normalises `yyyy-m-d` to zero-padded form; `validate_kickoff` and `validate_date` run after the `Field(pattern=...)` on `Match.kickoff` and `League.start`/`end` respectively. Derive `datetime.date` via `Match.date`.
77
+ **Dates are validated ISO strings, not `date` objects.** `Match.kickoff` requires a full offset-aware timestamp (strict `Field(pattern=...)`), `League.start`/`end` require `yyyy-mm-dd`. Four `WrapValidator` helpers layer a real-calendar check (via `datetime.date`/`datetime.datetime`) on top of each field's regex, so month 19 or 29 February in a non-leap year raises `ValueError` rather than validating: `validate_dob` and `validate_deduction_date` additionally accept the empty string, and `validate_dob` normalises `yyyy-m-d` to zero-padded form; `validate_kickoff` and `validate_date` run after the `Field(pattern=...)` on `Match.kickoff` and `League.start`/`end` respectively. Derive `datetime.date` via `Match.date`. **Exception:** `UserPublic.created_at` is a server-kept timestamp, not football data, so it is an offset-aware UTC `datetime` (stored by ilc-api as a BSON date, which keeps it sortable and queryable). `validate_created_at` treats naive values (pymongo's default) as UTC and converts aware ones to UTC; it defaults to `None` so stored users predating the field stay unknown rather than getting a load-time value, and only `User.create()` sets it.
62
78
 
63
79
  **`EventTime.plus` is only legal at the end of a half** (45/90/105/120), enforced by a `model_validator(mode="after")`.
64
80
 
@@ -66,7 +82,7 @@ Containment: `League` → `rounds: dict[str, list[Match]]` → `Match` → `Line
66
82
 
67
83
  ## Docs and docstrings
68
84
 
69
- Sphinx autodoc renders the whole module (`docs/source/api.rst` → `automodule:: ilc_models`) and publishes to Read the Docs. Public members need Google-style docstrings matching the existing ones (`Args:` / `Attributes:` / `Returns:` / `Raises:`, parsed by `sphinx.ext.napoleon`). `ruff`'s `D`/`D401` rules (Google convention, see `[tool.ruff.lint.pydocstyle]`) enforce presence and imperative mood as part of `just check`; `tests/*` and `docs/*` are exempted via `per-file-ignores`.
85
+ Sphinx autodoc renders the package docstring and then one section per submodule (`docs/source/api.rst` → `automodule:: ilc_models.<submodule>` with `:members:`) and publishes to Read the Docs. A new submodule needs its own section in `api.rst`. The top-level `automodule:: ilc_models` deliberately omits `:members:`, since the re-exports would otherwise document every object twice and fail the `-W` build with duplicate-object warnings. Public members need Google-style docstrings matching the existing ones (`Args:` / `Attributes:` / `Returns:` / `Raises:`, parsed by `sphinx.ext.napoleon`). `ruff`'s `D`/`D401` rules (Google convention, see `[tool.ruff.lint.pydocstyle]`) enforce presence and imperative mood as part of `just check`; `tests/*` and `docs/*` are exempted via `per-file-ignores`.
70
86
 
71
87
  Style conventions:
72
88
  - Method/function summaries are imperative ("Return the …", "Get the …", "Sort the …"); class summaries stay descriptive ("Represents a goal.").
@@ -78,7 +94,7 @@ Run `just docs` to build the docs locally (`-W`, so any Napoleon/autodoc warning
78
94
 
79
95
  ## Tests
80
96
 
81
- `tests/test_models.py` is a single file of `Test<Model>` classes. Fixtures come from the sibling `ilc_provider` package's Faker provider, exposed as the session-scoped `ilc_fake` fixture in `tests/conftest.py` (`ilc_fake.league()`, `.match()`, `.player()`, `.base_player()`, `.lineup()`, `.table_row()`, …) — prefer these over hand-built models.
97
+ Tests mirror the package layout: one `tests/test_<submodule>.py` per submodule, each holding `Test<Model>` classes (e.g. `test_league.py` has `TestLeague` and `TestLeagueTable`). `tests/test_init.py` checks the public interface: every `__all__` name is exported and is the same object as in its submodule. Fixtures come from the sibling `ilc_provider` package's Faker provider, exposed as the session-scoped `ilc_fake` fixture in `tests/conftest.py` (`ilc_fake.league()`, `.match()`, `.player()`, `.base_player()`, `.lineup()`, `.table_row()`, …) — prefer these over hand-built models.
82
98
 
83
99
  Two hazards: `pytest-randomly` shuffles test order, and the `fake_league` fixture is session-scoped but holds mutable models, so a test that mutates it can leak into others. Build a fresh `ilc_fake.league()` when mutating.
84
100
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: ilc-models
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Data models for the ILC project
5
5
  Project-URL: Repository, https://github.com/fourtreestech/ilc-models
6
6
  Project-URL: Documentation, https://ilc-models.readthedocs.io/
@@ -13,6 +13,7 @@ Classifier: Natural Language :: English
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Programming Language :: Python :: 3.15
16
17
  Classifier: Topic :: Software Development :: Libraries
17
18
  Classifier: Typing :: Typed
18
19
  Requires-Python: >=3.12
@@ -22,7 +23,7 @@ Description-Content-Type: text/markdown
22
23
 
23
24
  # ilc-models
24
25
 
25
- ![version](https://img.shields.io/badge/version-0.3.0-blue)
26
+ ![version](https://img.shields.io/badge/version-0.3.2-blue)
26
27
  ![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Ffourtreestech%2Filc-models%2Fmain%2Fpyproject.toml)
27
28
  ![coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
28
29
 
@@ -107,7 +108,16 @@ every `Player` who has featured in the league, keyed by `player_id` as a
107
108
  string.
108
109
 
109
110
  Users are modelled separately: `User` (the stored shape, including
110
- `password_hash`) subclasses `UserPublic` (just `email`).
111
+ `password_hash`) subclasses `UserPublic` (`email`, `username`, `status`,
112
+ `created_at` and `teams`).
113
+
114
+ ### Package layout
115
+
116
+ The models live in submodules grouped by domain: `player`, `lineup`,
117
+ `event`, `match`, `table` (`TableRow`, `RowTuple`, `Deduction`), `league`
118
+ and `user`. Every public name is re-exported from the top-level package, so
119
+ always import from `ilc_models` directly (e.g.
120
+ `from ilc_models import League, Match`) rather than from a submodule.
111
121
 
112
122
  ## Users
113
123
 
@@ -126,10 +136,14 @@ if user.verify_password(attempt) and user.needs_rehash():
126
136
  # ...then persist the user
127
137
  ```
128
138
 
129
- `User.create` hashes the password with argon2 and never stores it. To load a
130
- user from the database, pass the stored hash instead:
131
- `User(email=..., password_hash=...)`. Supplying both `password` and
132
- `password_hash` raises an error.
139
+ `User.create` hashes the password with argon2 and never stores it. `username`
140
+ defaults to the part of the email address before the `@`, and `status` to
141
+ `"pending"` (the other value is `"active"`); both can be passed as keyword
142
+ arguments, as can `teams`, the user's favourite teams. `created_at` is set to
143
+ the current UTC time. To load a user from the database, pass the stored hash
144
+ instead: `User(email=..., username=..., password_hash=...)`. Supplying both
145
+ `password` and `password_hash` raises an error. A loaded user without a
146
+ stored `created_at` keeps it as `None`.
133
147
 
134
148
  > **Warning:** `User.model_dump()` includes `password_hash`. Anything that
135
149
  > leaves the API should use `UserPublic` (e.g. FastAPI's
@@ -160,7 +174,8 @@ detail:
160
174
  - **Dates are validated ISO strings, not `date` objects.** `Match.kickoff`
161
175
  is a full offset-aware timestamp; `League.start`/`end` and
162
176
  `Deduction.date` are `yyyy-mm-dd`. Use `Match.date` to get a
163
- `datetime.date`.
177
+ `datetime.date`. The exception is `UserPublic.created_at`, an offset-aware
178
+ UTC `datetime`.
164
179
  - **`EventTime.plus` (stoppage time) is only valid at the end of a half** —
165
180
  i.e. when `minutes` is 45, 90, 105 or 120.
166
181
 
@@ -181,7 +196,7 @@ just check # ruff check --fix, ruff format, then ty check (type checking)
181
196
  just test # run tests with pytest
182
197
  just cov # pytest with coverage, then regenerate the coverage badge
183
198
  just docs # build the Sphinx docs locally
184
- just tox # run the tests across Python 3.12-3.14 and lowest/highest dependencies
199
+ just tox # run the tests across Python 3.12-3.15 and lowest/highest dependencies
185
200
  ```
186
201
 
187
202
  ## License
@@ -1,6 +1,6 @@
1
1
  # ilc-models
2
2
 
3
- ![version](https://img.shields.io/badge/version-0.3.0-blue)
3
+ ![version](https://img.shields.io/badge/version-0.3.2-blue)
4
4
  ![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Ffourtreestech%2Filc-models%2Fmain%2Fpyproject.toml)
5
5
  ![coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
6
6
 
@@ -85,7 +85,16 @@ every `Player` who has featured in the league, keyed by `player_id` as a
85
85
  string.
86
86
 
87
87
  Users are modelled separately: `User` (the stored shape, including
88
- `password_hash`) subclasses `UserPublic` (just `email`).
88
+ `password_hash`) subclasses `UserPublic` (`email`, `username`, `status`,
89
+ `created_at` and `teams`).
90
+
91
+ ### Package layout
92
+
93
+ The models live in submodules grouped by domain: `player`, `lineup`,
94
+ `event`, `match`, `table` (`TableRow`, `RowTuple`, `Deduction`), `league`
95
+ and `user`. Every public name is re-exported from the top-level package, so
96
+ always import from `ilc_models` directly (e.g.
97
+ `from ilc_models import League, Match`) rather than from a submodule.
89
98
 
90
99
  ## Users
91
100
 
@@ -104,10 +113,14 @@ if user.verify_password(attempt) and user.needs_rehash():
104
113
  # ...then persist the user
105
114
  ```
106
115
 
107
- `User.create` hashes the password with argon2 and never stores it. To load a
108
- user from the database, pass the stored hash instead:
109
- `User(email=..., password_hash=...)`. Supplying both `password` and
110
- `password_hash` raises an error.
116
+ `User.create` hashes the password with argon2 and never stores it. `username`
117
+ defaults to the part of the email address before the `@`, and `status` to
118
+ `"pending"` (the other value is `"active"`); both can be passed as keyword
119
+ arguments, as can `teams`, the user's favourite teams. `created_at` is set to
120
+ the current UTC time. To load a user from the database, pass the stored hash
121
+ instead: `User(email=..., username=..., password_hash=...)`. Supplying both
122
+ `password` and `password_hash` raises an error. A loaded user without a
123
+ stored `created_at` keeps it as `None`.
111
124
 
112
125
  > **Warning:** `User.model_dump()` includes `password_hash`. Anything that
113
126
  > leaves the API should use `UserPublic` (e.g. FastAPI's
@@ -138,7 +151,8 @@ detail:
138
151
  - **Dates are validated ISO strings, not `date` objects.** `Match.kickoff`
139
152
  is a full offset-aware timestamp; `League.start`/`end` and
140
153
  `Deduction.date` are `yyyy-mm-dd`. Use `Match.date` to get a
141
- `datetime.date`.
154
+ `datetime.date`. The exception is `UserPublic.created_at`, an offset-aware
155
+ UTC `datetime`.
142
156
  - **`EventTime.plus` (stoppage time) is only valid at the end of a half** —
143
157
  i.e. when `minutes` is 45, 90, 105 or 120.
144
158
 
@@ -159,7 +173,7 @@ just check # ruff check --fix, ruff format, then ty check (type checking)
159
173
  just test # run tests with pytest
160
174
  just cov # pytest with coverage, then regenerate the coverage badge
161
175
  just docs # build the Sphinx docs locally
162
- just tox # run the tests across Python 3.12-3.14 and lowest/highest dependencies
176
+ just tox # run the tests across Python 3.12-3.15 and lowest/highest dependencies
163
177
  ```
164
178
 
165
179
  ## License
@@ -1,36 +1,37 @@
1
1
  alabaster==1.0.0
2
2
  annotated-types==0.8.0
3
3
  argon2-cffi==25.1.0
4
- argon2-cffi-bindings==26.1.0
5
- babel==2.18.0
6
- certifi==2026.7.22
4
+ argon2-cffi-bindings==26.2.0
5
+ babel==2.19.0
6
+ certifi==2026.11.20
7
7
  cffi==2.1.1
8
- charset-normalizer==3.5.2
8
+ charset-normalizer==3.5.3
9
9
  colorama==0.4.6 ; sys_platform == 'win32'
10
- dnspython==2.9.0
10
+ dnspython==2.9.2
11
11
  docutils==0.22.4
12
- email-validator==2.3.0
12
+ email-validator==2.4.0
13
13
  idna==3.20
14
14
  imagesize==2.0.1
15
15
  jinja2==3.1.6
16
16
  markupsafe==3.0.4
17
- packaging==26.3
18
- pycparser==3.11 ; implementation_name != 'PyPy'
19
- pydantic==2.14.1
20
- pydantic-core==2.50.1
17
+ packaging==26.4
18
+ pycparser==3.12 ; implementation_name != 'PyPy'
19
+ pydantic==2.14.4
20
+ pydantic-core==2.50.5
21
21
  pygments==2.21.0
22
22
  requests==2.34.2
23
23
  roman-numerals==4.1.0
24
24
  snowballstemmer==3.1.1
25
- sphinx==9.1.0
25
+ sphinx==9.1.1 ; python_full_version < '3.13'
26
+ sphinx==9.2.0 ; python_full_version >= '3.13'
26
27
  sphinx-rtd-theme==3.1.0
27
28
  sphinxcontrib-applehelp==2.0.0
28
29
  sphinxcontrib-devhelp==2.0.0
29
30
  sphinxcontrib-htmlhelp==2.1.0
30
31
  sphinxcontrib-jquery==4.1
31
- sphinxcontrib-jsmath==1.0.1
32
+ sphinxcontrib-jsmath==2.0.0
32
33
  sphinxcontrib-qthelp==2.0.0
33
34
  sphinxcontrib-serializinghtml==2.0.0
34
35
  typing-extensions==4.16.0
35
- typing-inspection==0.4.4
36
+ typing-inspection==0.4.5
36
37
  urllib3==2.8.0
@@ -0,0 +1,59 @@
1
+ API
2
+ ===
3
+
4
+ The models are organised into submodules by domain, documented below. Every
5
+ public name is re-exported from the top-level package, so import them from
6
+ `ilc_models` directly rather than from a submodule::
7
+
8
+ from ilc_models import League, Match, User
9
+
10
+ .. automodule:: ilc_models
11
+
12
+ Players
13
+ -------
14
+
15
+ .. automodule:: ilc_models.player
16
+ :members:
17
+ :exclude-members: model_config
18
+
19
+ Lineups
20
+ -------
21
+
22
+ .. automodule:: ilc_models.lineup
23
+ :members:
24
+ :exclude-members: model_config
25
+
26
+ Events
27
+ ------
28
+
29
+ .. automodule:: ilc_models.event
30
+ :members:
31
+ :exclude-members: model_config
32
+
33
+ Matches
34
+ -------
35
+
36
+ .. automodule:: ilc_models.match
37
+ :members:
38
+ :exclude-members: model_config
39
+
40
+ League tables
41
+ -------------
42
+
43
+ .. automodule:: ilc_models.table
44
+ :members:
45
+ :exclude-members: model_config
46
+
47
+ Leagues
48
+ -------
49
+
50
+ .. automodule:: ilc_models.league
51
+ :members:
52
+ :exclude-members: model_config
53
+
54
+ Users
55
+ -----
56
+
57
+ .. automodule:: ilc_models.user
58
+ :members:
59
+ :exclude-members: model_config
@@ -15,7 +15,7 @@ sys.path.insert(0, str(Path("..", "..", "src").resolve()))
15
15
  project = "ilc-models"
16
16
  copyright = "2025, Neil Martin"
17
17
  author = "Neil Martin"
18
- release = "0.3.0"
18
+ release = "0.3.2"
19
19
 
20
20
  # -- General configuration ---------------------------------------------------
21
21
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -147,7 +147,7 @@ the number of matches each team plays before the league splits into top and
147
147
  bottom halves (see `League tables`_); the default of `0` means no split.
148
148
 
149
149
  `matches(team=, teams=, h2h=, player=)` returns every match across all
150
- rounds, sorted by date and then home team name. The first four filters
150
+ rounds, sorted by date and then home team name. The four filters
151
151
  follow the same rules as `Match.involves`, `Match.involves_any`,
152
152
  `Match.h2h` and `Match.players` (for `player`). They are alternatives, not
153
153
  combinable: if you pass more than one, only the first applies, in the order
@@ -238,14 +238,28 @@ value like month 19 or 29 February in a non-leap year raises `ValueError`
238
238
  even though it matches the format. Use `Match.date` to get a `datetime.date`
239
239
  from `kickoff` rather than parsing the string yourself.
240
240
 
241
- The one exception is `EventInfo.date`, which is a real `datetime.date`: it is
242
- produced by `League.events` from `Match.date`.
241
+ There are two exceptions. `EventInfo.date` is a real `datetime.date`,
242
+ produced by `League.events` from `Match.date`. `UserPublic.created_at` is an
243
+ offset-aware UTC `datetime`, because it is a server-kept timestamp rather
244
+ than football data (see `Users`_).
243
245
 
244
246
  Users
245
247
  -----
246
248
 
247
249
  `UserPublic` is the shape that is safe to send out of the API: it holds only
248
- `email` (validated as an email address). `User` is the stored shape, a
250
+ `email` (validated as an email address), `username`, `status` (`"pending"`
251
+ or `"active"`, defaulting to `"pending"`), `created_at` and `teams`.
252
+
253
+ * `created_at` is an offset-aware UTC `datetime`, or `None` if unknown. A
254
+ naive value, which is what pymongo returns by default, is treated as UTC,
255
+ and an aware one is converted to UTC. Only `User.create` fills it in, so a
256
+ stored user without one keeps `None` when loaded.
257
+ * `teams` lists the user's favourite teams (default `[]`). Names are
258
+ stripped of surrounding whitespace, empty names are dropped and duplicates
259
+ removed, keeping the first occurrence. Case is preserved, so `"Celtic"` and
260
+ `"celtic"` count as different teams.
261
+
262
+ `User` is the stored shape, a
249
263
  subclass of `UserPublic` that adds `password_hash`, an argon2 hash of the
250
264
  user's password. Fields that must never leave the API belong on `User` only,
251
265
  so API endpoints should declare `response_model=UserPublic`.
@@ -255,11 +269,18 @@ There are two ways to build a `User`:
255
269
  * From a plain text password, which is hashed and not kept::
256
270
 
257
271
  user = User.create("alice@example.com", "s3cret")
258
- # equivalent: User.model_validate({"email": ..., "password": ...})
272
+ # username defaults to "alice", status to "pending" and teams to [];
273
+ # override with User.create(..., username="al", status="active",
274
+ # teams=["Hibernian"]). created_at is set to the current UTC time.
275
+ # equivalent: User.model_validate(
276
+ # {"email": ..., "username": ..., "password": ...}
277
+ # )
259
278
 
260
279
  * From a hash loaded from the database::
261
280
 
262
- user = User(email="alice@example.com", password_hash=stored_hash)
281
+ user = User(
282
+ email="alice@example.com", username="alice", password_hash=stored_hash
283
+ )
263
284
 
264
285
  Supplying both `password` and `password_hash` raises a `ValidationError`, as
265
286
  does an empty or non-string password. `password_hash` is left out of the
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ilc-models"
3
- version = "0.3.0"
3
+ version = "0.3.2"
4
4
  description = "Data models for the ILC project"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -21,6 +21,7 @@ classifiers = [
21
21
  "Programming Language :: Python :: 3.12",
22
22
  "Programming Language :: Python :: 3.13",
23
23
  "Programming Language :: Python :: 3.14",
24
+ "Programming Language :: Python :: 3.15",
24
25
  ]
25
26
 
26
27
  [project.urls]
@@ -32,7 +33,7 @@ requires = ["hatchling"]
32
33
  build-backend = "hatchling.build"
33
34
 
34
35
  [tool.bumpver]
35
- current_version = "0.3.0"
36
+ current_version = "0.3.2"
36
37
  version_pattern = "MAJOR.MINOR.PATCH"
37
38
  commit_message = "Bump version {old_version} -> {new_version}"
38
39
  tag_message = "{new_version}"
@@ -72,7 +73,7 @@ convention = "google"
72
73
 
73
74
  [tool.tox]
74
75
  requires = ["tox>=4.24", "tox-uv>=1.37.0"]
75
- env_list = ["3.14", "3.13", "3.12", "lowest", "highest"]
76
+ env_list = ["3.15", "3.14", "3.13", "3.12", "lowest", "highest"]
76
77
 
77
78
  [tool.tox.env_run_base]
78
79
  description = "Run tests under {base_python}"
@@ -82,18 +83,23 @@ dependency_groups = ["test"]
82
83
  commands = [["pytest"]]
83
84
 
84
85
  [tool.tox.env.lowest]
85
- description = "Run tests under {base_python} with lowest dependency versions"
86
+ description = "Run tests under {base_python} with lowest direct dependency versions"
86
87
  runner = "uv-venv-runner"
87
88
  base_python = ["python3.12"]
88
89
  skip_install = true
89
90
  dependency_groups = []
90
91
  allowlist_externals = ["uv"]
91
- commands_pre = [["uv", "pip", "install", "--resolution", "lowest", "-e", ".", "--group", "pyproject.toml:test", "tzdata>=2025.1", "cffi>=1.16.0"]]
92
+ # lowest-direct floors only direct dependencies; transitive ones (email-validator,
93
+ # cffi, argon2-cffi-bindings, pycparser, tzdata) resolve to their newest releases.
94
+ # If switching back to `--resolution lowest`, restore the floor pins
95
+ # "tzdata>=2025.1", "cffi>=1.16.0", "argon2-cffi-bindings>=21.2.0" and
96
+ # "pycparser>=2.21", which stop it picking ancient builds with no 3.12 wheels.
97
+ commands_pre = [["uv", "pip", "install", "--resolution", "lowest-direct", "-e", ".", "--group", "pyproject.toml:test"]]
92
98
 
93
99
  [tool.tox.env.highest]
94
100
  description = "Run tests under {base_python} with highest dependency versions"
95
101
  runner = "uv-venv-runner"
96
- base_python = ["python3.14"]
102
+ base_python = ["python3.15"]
97
103
  skip_install = true
98
104
  dependency_groups = []
99
105
  allowlist_externals = ["uv"]
@@ -0,0 +1,57 @@
1
+ """Data models for the ILC project.
2
+
3
+ Pure Pydantic models with no I/O, forming the shared data contract between
4
+ ilc-api, ilc-app and ilc-admin.
5
+
6
+ The models are split across submodules by domain, but every public name is
7
+ re-exported here, so import from `ilc_models` directly, e.g.
8
+ `from ilc_models import League, Match`.
9
+ """
10
+
11
+ from .event import (
12
+ BaseEvent,
13
+ Card,
14
+ Event,
15
+ EventTime,
16
+ Goal,
17
+ LineupStatus,
18
+ Substitution,
19
+ )
20
+ from .league import League, validate_date
21
+ from .lineup import Lineup, Lineups
22
+ from .match import EventInfo, Match, Score, Teams, validate_kickoff
23
+ from .player import BasePlayer, Player, validate_dob
24
+ from .table import Deduction, RowTuple, TableRow, validate_deduction_date
25
+ from .user import User, UserPublic, validate_created_at, validate_teams
26
+
27
+ __version__ = "0.3.2"
28
+
29
+ __all__ = [
30
+ "BaseEvent",
31
+ "BasePlayer",
32
+ "Card",
33
+ "Deduction",
34
+ "Event",
35
+ "EventInfo",
36
+ "EventTime",
37
+ "Goal",
38
+ "League",
39
+ "Lineup",
40
+ "LineupStatus",
41
+ "Lineups",
42
+ "Match",
43
+ "Player",
44
+ "RowTuple",
45
+ "Score",
46
+ "Substitution",
47
+ "TableRow",
48
+ "Teams",
49
+ "User",
50
+ "UserPublic",
51
+ "validate_created_at",
52
+ "validate_date",
53
+ "validate_deduction_date",
54
+ "validate_dob",
55
+ "validate_kickoff",
56
+ "validate_teams",
57
+ ]