Skip to main content

ilc-models

version Python Version from PEP 621 TOML coverage

ilc-models contains all data models for the ILC project.

It's a set of pure Pydantic v2 models with no I/O and no dependency beyond pydantic — a League of Match objects, each with its Lineups, Goal/Card/Substitution events, and the TableRow results computed from them. This package is the shared data contract used across the ilc-api, ilc-app and ilc-admin repositories, so a field change here is a breaking change for all three.

Installation

pip install ilc-models

Or with uv:

uv add ilc-models

Quick start

from ilc_models import League, Match, Teams, Score

league = League(
    league_id=1,
    name="Premiership",
    year=2025,
    start="2025-08-01",
    end="2026-05-01",
    current=True,
    coverage={"lineups": True},
    teams=["Team A", "Team B"],
    rounds={
        "1": [
            Match(
                match_id=1,
                kickoff="2025-08-09T15:00:00+01:00",
                round="1",
                teams=Teams(home="Team A", away="Team B"),
                status="FT",
                score=Score(home=2, away=1),
            )
        ]
    },
)

for row in league.table():
    print(row)

Model map

League
 rounds: dict[str, list[Match]]
    Match
       teams: Teams          # home / away team names
       score: Score          # home / away goals
       goals: list[Goal]
       cards: list[Card]
       substitutions: list[Substitution]
       lineups: Lineups
          home: Lineup
          away: Lineup
             starting: list[tuple[int, BasePlayer]]   # shirt_no, player
             subs: list[tuple[int, BasePlayer]]

Goal, Card, Substitution and LineupStatus all subclass the abstract BaseEvent and are aliased together as Event. League.players holds every Player who has featured in the league, keyed by player_id as a string.

Conventions worth knowing

A few behaviours are deliberate and easy to trip over — see the full usage guide for detail:

  • Goal.team is the team credited with the goal, not the scorer's team. For an own goal the scorer belongs to the opposing team — call Match.event_team(event) to resolve the team a player in an event actually plays for.
  • Player equality compares player_id alone (falling back to name only when both IDs are 0), because the upstream API spells player names differently in event payloads versus player downloads.
  • League.table() models the Scottish-style split — once a team has played more than League.split matches, the table freezes the top/bottom halves by position at the split point and sorts each half independently.
  • Dates are validated ISO strings, not date objects. Match.kickoff is a full offset-aware timestamp; League.start/end and Deduction.date are yyyy-mm-dd. Use Match.date to get a datetime.date.
  • EventTime.plus (stoppage time) is only valid at the end of a half — i.e. when minutes is 45, 90, 105 or 120.

Documentation

Full API reference and usage guide: ilc-models.readthedocs.io

See CHANGELOG.md for release history.

Development

Task runner is just; Python tooling is uv.

just check   # ruff check --fix, ruff format, then ty check (type checking)
just test    # run tests with pytest
just cov     # pytest with coverage, then regenerate the coverage badge
just docs    # build the Sphinx docs locally

License

MIT — see LICENSE.txt.

Metadata

Release files for ilc-models 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ilc-models 0.2.4
File Size Uploaded Provenance
ilc_models-0.2.4.tar.gz 66.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ilc-models 0.2.4
File Interpreter ABI Platform
ilc_models-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 80.3 kB

Release files / ilc_models-0.2.4.tar.gz

Download URL ilc_models-0.2.4.tar.gz
Size 66.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bf1edf16c8733758faa76561812d1a931438a4ac8b9cd663b699fb650e0a0eb0
BLAKE2b-256 checksum
How to use checksums
268365ddba16cac6841ab2ca448fdbb278d0650514f4850dfafddf5c4bb9807c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / ilc_models-0.2.4-py3-none-any.whl

Download URL ilc_models-0.2.4-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5489e7dfde0905c5e48680cb19b7f6521a7efd90873f63388f51fd70a0c33895
BLAKE2b-256 checksum
How to use checksums
4428ed901edc4d836a7e90b3a2883ec1f95e71aaaf454f97b3521b85bc516fdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for ilc-models 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page