ilc-models 0.2.0__tar.gz → 0.2.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.
- {ilc_models-0.2.0 → ilc_models-0.2.2}/CHANGELOG.md +17 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/PKG-INFO +3 -3
- {ilc_models-0.2.0 → ilc_models-0.2.2}/README.md +1 -1
- ilc_models-0.2.2/coverage.zsh +3 -0
- ilc_models-0.2.2/docs/requirements.txt +30 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/docs/source/conf.py +1 -1
- {ilc_models-0.2.0 → ilc_models-0.2.2}/pyproject.toml +15 -13
- {ilc_models-0.2.0 → ilc_models-0.2.2}/src/ilc_models/__init__.py +63 -14
- {ilc_models-0.2.0 → ilc_models-0.2.2}/tests/test_models.py +88 -0
- ilc_models-0.2.2/uv.lock +828 -0
- ilc_models-0.2.0/docs/requirements.txt +0 -28
- ilc_models-0.2.0/uv.lock +0 -645
- {ilc_models-0.2.0 → ilc_models-0.2.2}/.gitignore +0 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/.python-version +0 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/.readthedocs.yaml +0 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/LICENSE.txt +0 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/check.zsh +0 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/docs/source/api.rst +0 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/docs/source/index.rst +0 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/src/ilc_models/py.typed +0 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/tests/__init__.py +0 -0
- {ilc_models-0.2.0 → ilc_models-0.2.2}/tests/conftest.py +0 -0
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.2] - 2026-01-21
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Add `team` parameter to `Match.players()` method
|
|
8
|
+
- Add `League.match_players()` method
|
|
9
|
+
|
|
10
|
+
## [0.2.1] - 2025-11-12
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Add form to `TableRow.from_tuple` method
|
|
15
|
+
|
|
3
16
|
## [0.2.0] - 2025-11-10
|
|
4
17
|
|
|
5
18
|
### Breaking
|
|
@@ -62,6 +75,10 @@
|
|
|
62
75
|
|
|
63
76
|
_Initial release._
|
|
64
77
|
|
|
78
|
+
[0.2.2]: https://github.com/fourtreestech/ilc-models/releases/tag/v0.2.2
|
|
79
|
+
|
|
80
|
+
[0.2.1]: https://github.com/fourtreestech/ilc-models/releases/tag/v0.2.1
|
|
81
|
+
|
|
65
82
|
[0.2.0]: https://github.com/fourtreestech/ilc-models/releases/tag/v0.2.0
|
|
66
83
|
|
|
67
84
|
[0.1.8]: https://github.com/fourtreestech/ilc-models/releases/tag/v0.1.8
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ilc-models
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Data models for the ILC project
|
|
5
5
|
Project-URL: Repository, https://github.com/fourtreestech/ilc-models
|
|
6
6
|
Author-email: Neil Martin <neil@fourtrees.tech>
|
|
@@ -14,12 +14,12 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
14
14
|
Classifier: Topic :: Software Development :: Libraries
|
|
15
15
|
Classifier: Typing :: Typed
|
|
16
16
|
Requires-Python: >=3.12
|
|
17
|
-
Requires-Dist: pydantic>=2.
|
|
17
|
+
Requires-Dist: pydantic>=2.12.5
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
|
|
20
20
|
# ilc-models
|
|
21
21
|
|
|
22
|
-

|
|
23
23
|

|
|
24
24
|

|
|
25
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ilc-models
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
alabaster==1.0.0
|
|
2
|
+
annotated-types==0.7.0
|
|
3
|
+
babel==2.17.0
|
|
4
|
+
certifi==2026.1.4
|
|
5
|
+
charset-normalizer==3.4.4
|
|
6
|
+
colorama==0.4.6 ; sys_platform == 'win32'
|
|
7
|
+
docutils==0.22.4
|
|
8
|
+
idna==3.11
|
|
9
|
+
imagesize==1.4.1
|
|
10
|
+
jinja2==3.1.6
|
|
11
|
+
markupsafe==3.0.3
|
|
12
|
+
packaging==25.0
|
|
13
|
+
pydantic==2.12.5
|
|
14
|
+
pydantic-core==2.41.5
|
|
15
|
+
pygments==2.19.1
|
|
16
|
+
requests==2.32.5
|
|
17
|
+
roman-numerals==4.1.0
|
|
18
|
+
snowballstemmer==3.0.1
|
|
19
|
+
sphinx==9.1.0
|
|
20
|
+
sphinx-rtd-theme==3.1.0
|
|
21
|
+
sphinxcontrib-applehelp==2.0.0
|
|
22
|
+
sphinxcontrib-devhelp==2.0.0
|
|
23
|
+
sphinxcontrib-htmlhelp==2.1.0
|
|
24
|
+
sphinxcontrib-jquery==4.1
|
|
25
|
+
sphinxcontrib-jsmath==1.0.1
|
|
26
|
+
sphinxcontrib-qthelp==2.0.0
|
|
27
|
+
sphinxcontrib-serializinghtml==2.0.0
|
|
28
|
+
typing-extensions==4.15.0
|
|
29
|
+
typing-inspection==0.4.2
|
|
30
|
+
urllib3==2.6.3
|
|
@@ -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.2.
|
|
18
|
+
release = "0.2.2"
|
|
19
19
|
|
|
20
20
|
# -- General configuration ---------------------------------------------------
|
|
21
21
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ilc-models"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.2"
|
|
4
4
|
description = "Data models for the ILC project"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -9,7 +9,7 @@ authors = [
|
|
|
9
9
|
requires-python = ">=3.12"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
dependencies = [
|
|
12
|
-
"pydantic>=2.
|
|
12
|
+
"pydantic>=2.12.5",
|
|
13
13
|
]
|
|
14
14
|
classifiers = [
|
|
15
15
|
"Development Status :: 4 - Beta",
|
|
@@ -29,7 +29,7 @@ requires = ["hatchling"]
|
|
|
29
29
|
build-backend = "hatchling.build"
|
|
30
30
|
|
|
31
31
|
[tool.bumpver]
|
|
32
|
-
current_version = "0.2.
|
|
32
|
+
current_version = "0.2.2"
|
|
33
33
|
version_pattern = "MAJOR.MINOR.PATCH"
|
|
34
34
|
commit_message = "Bump version {old_version} -> {new_version}"
|
|
35
35
|
tag_message = "{new_version}"
|
|
@@ -66,19 +66,21 @@ env_list = ["3.13", "3.12"]
|
|
|
66
66
|
|
|
67
67
|
[tool.tox.env_run_base]
|
|
68
68
|
description = "Run tests under {base_python}"
|
|
69
|
-
deps = ["pytest>=
|
|
69
|
+
deps = ["pytest>=9", "pytest-cov>=7", "pytest-randomly>=4", "ilc_provider>=0.1.3"]
|
|
70
70
|
commands = [["pytest"]]
|
|
71
71
|
|
|
72
72
|
[dependency-groups]
|
|
73
73
|
dev = [
|
|
74
|
-
"faker>=
|
|
75
|
-
"ilc-provider>=0.1.
|
|
76
|
-
"mypy>=1.
|
|
77
|
-
"pytest>=
|
|
78
|
-
"pytest-cov>=
|
|
79
|
-
"pytest-randomly>=
|
|
80
|
-
"rich>=
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
"faker>=40.1.2",
|
|
75
|
+
"ilc-provider>=0.1.3",
|
|
76
|
+
"mypy>=1.19.1",
|
|
77
|
+
"pytest>=9.0.2",
|
|
78
|
+
"pytest-cov>=7.0.0",
|
|
79
|
+
"pytest-randomly>=4.0.1",
|
|
80
|
+
"rich>=14.2.0",
|
|
81
|
+
]
|
|
82
|
+
docs = [
|
|
83
|
+
"sphinx>=9.1.0",
|
|
84
|
+
"sphinx-rtd-theme>=3.1.0",
|
|
83
85
|
]
|
|
84
86
|
|
|
@@ -18,7 +18,7 @@ from pydantic import (
|
|
|
18
18
|
model_validator,
|
|
19
19
|
)
|
|
20
20
|
|
|
21
|
-
__version__ = "0.2.
|
|
21
|
+
__version__ = "0.2.2"
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class RowTuple(NamedTuple):
|
|
@@ -464,13 +464,44 @@ class Match(BaseModel):
|
|
|
464
464
|
e = self.goals + self.cards + self.substitutions
|
|
465
465
|
return sorted(e, key=attrgetter("time"))
|
|
466
466
|
|
|
467
|
-
def players(self) -> list[BasePlayer]:
|
|
468
|
-
"""
|
|
469
|
-
|
|
467
|
+
def players(self, team: Optional[str] = None) -> list[BasePlayer]:
|
|
468
|
+
"""Get all players involved in this match.
|
|
469
|
+
|
|
470
|
+
If `team` is provided return only players from the team specified.
|
|
471
|
+
|
|
472
|
+
:param team: Return only players from this team (default=None)
|
|
473
|
+
:type team: str
|
|
474
|
+
:returns: Players involved in the match
|
|
475
|
+
:rtype: list[:class:`BasePlayer`]
|
|
476
|
+
"""
|
|
477
|
+
# Get players from lineups
|
|
478
|
+
if team:
|
|
479
|
+
if team == self.teams.home:
|
|
480
|
+
p = self.lineups.home.players()
|
|
481
|
+
elif team == self.teams.away:
|
|
482
|
+
p = self.lineups.away.players()
|
|
483
|
+
else:
|
|
484
|
+
return []
|
|
485
|
+
else:
|
|
486
|
+
p = self.lineups.players()
|
|
487
|
+
|
|
488
|
+
# Add players from events
|
|
470
489
|
for event in self.events():
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
490
|
+
add = False
|
|
491
|
+
if not team:
|
|
492
|
+
add = True
|
|
493
|
+
elif event.event_type == "goal":
|
|
494
|
+
add = (
|
|
495
|
+
(event.team == team)
|
|
496
|
+
if event.goal_type != "O"
|
|
497
|
+
else (event.team != team)
|
|
498
|
+
)
|
|
499
|
+
else:
|
|
500
|
+
add = event.team == team
|
|
501
|
+
if add:
|
|
502
|
+
for player in event.players():
|
|
503
|
+
if player not in p:
|
|
504
|
+
p.append(player)
|
|
474
505
|
return p
|
|
475
506
|
|
|
476
507
|
def delete_event(self, event: Event) -> bool:
|
|
@@ -651,12 +682,13 @@ class TableRow(BaseModel):
|
|
|
651
682
|
:rtype: :class:`TableRow`
|
|
652
683
|
"""
|
|
653
684
|
return cls(
|
|
654
|
-
team=row_tuple
|
|
655
|
-
won=row_tuple
|
|
656
|
-
drawn=row_tuple
|
|
657
|
-
lost=row_tuple
|
|
658
|
-
scored=row_tuple
|
|
659
|
-
conceded=row_tuple
|
|
685
|
+
team=row_tuple.team,
|
|
686
|
+
won=row_tuple.won,
|
|
687
|
+
drawn=row_tuple.drawn,
|
|
688
|
+
lost=row_tuple.lost,
|
|
689
|
+
scored=row_tuple.goals_for,
|
|
690
|
+
conceded=row_tuple.goals_against,
|
|
691
|
+
form=row_tuple.form,
|
|
660
692
|
)
|
|
661
693
|
|
|
662
694
|
def __eq__(self, other: Any) -> bool:
|
|
@@ -816,7 +848,7 @@ class League(BaseModel):
|
|
|
816
848
|
:param split: Split point of this league (default=0)
|
|
817
849
|
:type split: int
|
|
818
850
|
:param players: Players who feature in this league
|
|
819
|
-
:type players: dict[
|
|
851
|
+
:type players: dict[str, :class:`Player`]
|
|
820
852
|
"""
|
|
821
853
|
|
|
822
854
|
league_id: PositiveInt
|
|
@@ -1045,6 +1077,23 @@ class League(BaseModel):
|
|
|
1045
1077
|
|
|
1046
1078
|
return list(teams)
|
|
1047
1079
|
|
|
1080
|
+
def match_players(self, team: Optional[str] = None) -> list[BasePlayer]:
|
|
1081
|
+
"""Get all players involved in at least one match in this league.
|
|
1082
|
+
|
|
1083
|
+
If `team` is given return only players who have featured for this team.
|
|
1084
|
+
|
|
1085
|
+
:param team: Get players who played for this team (default=None)
|
|
1086
|
+
:type team: str
|
|
1087
|
+
:returns: All players involved in a match
|
|
1088
|
+
:rtype: list[:class:`BasePlayer`]
|
|
1089
|
+
"""
|
|
1090
|
+
players = []
|
|
1091
|
+
for match in self.matches(team=team):
|
|
1092
|
+
for p in match.players(team=team):
|
|
1093
|
+
if p not in players:
|
|
1094
|
+
players.append(p)
|
|
1095
|
+
return players
|
|
1096
|
+
|
|
1048
1097
|
def table(
|
|
1049
1098
|
self,
|
|
1050
1099
|
played: int = 0,
|
|
@@ -373,6 +373,56 @@ class TestMatch:
|
|
|
373
373
|
match.lineups = Lineups()
|
|
374
374
|
assert match.players()
|
|
375
375
|
|
|
376
|
+
def test_players_from_team(self, ilc_fake):
|
|
377
|
+
match = ilc_fake.match()
|
|
378
|
+
team = match.teams.home
|
|
379
|
+
players = match.players(team=team)
|
|
380
|
+
for player in match.lineups.home.starting:
|
|
381
|
+
assert player[1] in players
|
|
382
|
+
for player in match.lineups.away.starting:
|
|
383
|
+
assert player[1] not in players
|
|
384
|
+
|
|
385
|
+
def test_team_players_from_events(self, ilc_fake):
|
|
386
|
+
match = ilc_fake.match()
|
|
387
|
+
match.lineups = Lineups()
|
|
388
|
+
team = match.teams.home
|
|
389
|
+
players = match.players(team=team)
|
|
390
|
+
for event in match.events():
|
|
391
|
+
if event.team == team and not (
|
|
392
|
+
event.event_type == "goal" and event.goal_type == "O"
|
|
393
|
+
):
|
|
394
|
+
for player in event.players():
|
|
395
|
+
assert player in players
|
|
396
|
+
|
|
397
|
+
def test_own_goal_scorer_to_correct_team(self, ilc_fake):
|
|
398
|
+
home = ilc_fake.team()
|
|
399
|
+
away = ilc_fake.team()
|
|
400
|
+
match = ilc_fake.match(home=home, away=away)
|
|
401
|
+
home_players = [player[1] for player in match.lineups.home.starting]
|
|
402
|
+
away_players = [player[1] for player in match.lineups.away.starting]
|
|
403
|
+
match.cards = []
|
|
404
|
+
match.substitutions = []
|
|
405
|
+
|
|
406
|
+
# Generate an own goal for the home team
|
|
407
|
+
match.goals = [
|
|
408
|
+
ilc_fake.goal(
|
|
409
|
+
team=home,
|
|
410
|
+
goal_type="O",
|
|
411
|
+
players=(home_players, away_players),
|
|
412
|
+
)
|
|
413
|
+
]
|
|
414
|
+
match.lineups = Lineups()
|
|
415
|
+
|
|
416
|
+
# There should be one away player returned
|
|
417
|
+
assert not match.players(team=match.teams.home)
|
|
418
|
+
players = match.players(team=match.teams.away)
|
|
419
|
+
assert len(players) == 1
|
|
420
|
+
assert players[0] in away_players
|
|
421
|
+
|
|
422
|
+
def test_invalid_team_returns_empty_list(self, ilc_fake):
|
|
423
|
+
match = ilc_fake.match()
|
|
424
|
+
assert not match.players(team="ABCDEFG")
|
|
425
|
+
|
|
376
426
|
def test_str_gives_score(self, ilc_fake):
|
|
377
427
|
match = ilc_fake.match()
|
|
378
428
|
assert " - ".join((str(match.score.home), str(match.score.away))) in str(match)
|
|
@@ -458,6 +508,18 @@ class TestTableRow:
|
|
|
458
508
|
row.add_form("L")
|
|
459
509
|
assert row.form == "WLDWL"
|
|
460
510
|
|
|
511
|
+
def test_as_tuple_populates_form(self, ilc_fake):
|
|
512
|
+
row = ilc_fake.table_row()
|
|
513
|
+
row.form = "WDLLW"
|
|
514
|
+
row2 = row.as_tuple()
|
|
515
|
+
assert row2.form == "WDLLW"
|
|
516
|
+
|
|
517
|
+
def test_from_tuple_populates_form(self, ilc_fake):
|
|
518
|
+
row = ilc_fake.table_row()
|
|
519
|
+
row.form = "WDLLW"
|
|
520
|
+
row2 = TableRow.from_tuple(row.as_tuple())
|
|
521
|
+
assert row2.form == "WDLLW"
|
|
522
|
+
|
|
461
523
|
|
|
462
524
|
class TestLeague:
|
|
463
525
|
def test_title(self, fake_league):
|
|
@@ -662,6 +724,32 @@ class TestLeague:
|
|
|
662
724
|
for t1, t2 in itertools.permutations(league.teams, r=2):
|
|
663
725
|
assert len(league.head_to_head((t1, t2))) == 2
|
|
664
726
|
|
|
727
|
+
def test_match_players_includes_all_players(self, fake_league):
|
|
728
|
+
players = fake_league.match_players()
|
|
729
|
+
# Select a random player from a random match
|
|
730
|
+
# and check he is in the players list
|
|
731
|
+
match = random.choice(fake_league.matches())
|
|
732
|
+
player = random.choice(match.players())
|
|
733
|
+
assert player in players
|
|
734
|
+
|
|
735
|
+
def test_match_players_includes_no_duplicates(self, fake_league):
|
|
736
|
+
players = fake_league.match_players()
|
|
737
|
+
ids = {player.player_id for player in players}
|
|
738
|
+
assert len(ids) == len(players)
|
|
739
|
+
|
|
740
|
+
def test_match_players_returns_for_team(self, fake_league):
|
|
741
|
+
team = random.choice(fake_league.teams)
|
|
742
|
+
players = fake_league.match_players(team=team)
|
|
743
|
+
matches = fake_league.matches(team=team)
|
|
744
|
+
match = random.choice(matches)
|
|
745
|
+
# All players featuring for team in this match
|
|
746
|
+
# should be in the player list
|
|
747
|
+
lineup = match.lineups.home if team == match.teams.home else match.lineups.away
|
|
748
|
+
for player in lineup.starting:
|
|
749
|
+
assert player[1] in players
|
|
750
|
+
for player in lineup.subs:
|
|
751
|
+
assert player[1] in players
|
|
752
|
+
|
|
665
753
|
|
|
666
754
|
class TestLeagueTable:
|
|
667
755
|
def test_league_table_is_correct_size(self, fake_league):
|