python-espncricinfo 1.1.0__tar.gz → 1.2.0__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.
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-espncricinfo
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Python client for ESPNcricinfo match, series, season, team and player data
5
5
  Keywords: espncricinfo,cricket,t20,odi,test cricket,scorecard,sports data
6
6
  Author: Derek Willis, Gaurav Sood
7
- Author-email: Derek Willis <dwillis@gmail.com>, Gaurav Sood <gsood07@gmail.com>
7
+ Author-email: Derek Willis <dwillis@gmail.com>
8
8
  License-Expression: MIT
9
9
  License-File: LICENSE.txt
10
10
  Classifier: Development Status :: 4 - Beta
@@ -13,17 +13,16 @@ Classifier: Intended Audience :: Science/Research
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Programming Language :: Python :: 3 :: Only
16
- Classifier: Programming Language :: Python :: 3.12
17
16
  Classifier: Programming Language :: Python :: 3.13
18
17
  Classifier: Programming Language :: Python :: 3.14
19
18
  Classifier: Topic :: Internet :: WWW/HTTP
20
19
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
- Requires-Dist: requests
22
- Requires-Dist: beautifulsoup4
23
- Requires-Dist: dateparser
24
- Requires-Dist: lxml
20
+ Requires-Dist: requests>=2.32.2
21
+ Requires-Dist: beautifulsoup4>=4.12.3
22
+ Requires-Dist: dateparser>=1.2.1
23
+ Requires-Dist: lxml>=5.3.0
25
24
  Requires-Dist: playwright>=1.48.0
26
- Requires-Python: >=3.12
25
+ Requires-Python: >=3.13
27
26
  Project-URL: Homepage, https://github.com/outside-edge/python-espncricinfo
28
27
  Project-URL: Repository, https://github.com/outside-edge/python-espncricinfo
29
28
  Project-URL: Documentation, https://outside-edge.github.io/python-espncricinfo/
@@ -83,7 +82,7 @@ MatchRef(series_id=1523975, match_id=1523981)
83
82
  >>> series_id, match_id = refs[0] # MatchRefs unpack like tuples
84
83
  ```
85
84
 
86
- For one day only, `Match.get_matches_on("2026-10-20")` keeps the matches played that day, multi-day matches included on each of their days. `Summary(date=...)` wraps the same call; its result is in `.matches`.
85
+ For one day only, `Match.get_matches_on("2026-10-20")` keeps the matches played that day, multi-day matches included on each of their days. `Summary(date=...).matches` is the two-week window from `Match.get_recent_matches`, not one day.
87
86
 
88
87
  ## A single match
89
88
 
@@ -50,7 +50,7 @@ MatchRef(series_id=1523975, match_id=1523981)
50
50
  >>> series_id, match_id = refs[0] # MatchRefs unpack like tuples
51
51
  ```
52
52
 
53
- For one day only, `Match.get_matches_on("2026-10-20")` keeps the matches played that day, multi-day matches included on each of their days. `Summary(date=...)` wraps the same call; its result is in `.matches`.
53
+ For one day only, `Match.get_matches_on("2026-10-20")` keeps the matches played that day, multi-day matches included on each of their days. `Summary(date=...).matches` is the two-week window from `Match.get_recent_matches`, not one day.
54
54
 
55
55
  ## A single match
56
56
 
@@ -89,6 +89,26 @@ def _boundary_count(inn: dict[str, Any], key: str) -> int | None:
89
89
  return sum(counts)
90
90
 
91
91
 
92
+ def _run_rate(inn: dict[str, Any]) -> float:
93
+ """Runs per over for an innings; 0.0 before a ball is bowled.
94
+
95
+ ESPN writes overs in cricket notation, where 19.4 is 19 overs and 4 balls,
96
+ so dividing runs by it overstates the rate of an innings that ends
97
+ mid-over. Count balls instead: ESPN's ``balls``, else the overs figure
98
+ converted with ``ballsPerOver`` (6 unless ESPN says otherwise).
99
+ """
100
+ try:
101
+ runs = inn.get("runs") or 0
102
+ per_over = inn.get("ballsPerOver") or 6
103
+ balls = inn.get("balls")
104
+ if not balls:
105
+ overs = float(inn.get("overs") or 0)
106
+ balls = int(overs) * per_over + round(overs % 1 * 10)
107
+ return round(runs * per_over / balls, 2) if balls > 0 else 0.0
108
+ except (TypeError, ValueError, ZeroDivisionError):
109
+ return 0.0
110
+
111
+
92
112
  def _as_float(record: dict[str, Any] | None, key: str) -> float | None:
93
113
  """Return ``record[key]`` as a float, or None if absent or not numeric."""
94
114
  if record is None:
@@ -183,10 +203,7 @@ def _normalize(next_data, match_id, series_id):
183
203
  for inn in innings_raw:
184
204
  overs = inn.get("overs") or 0
185
205
  runs = inn.get("runs") or 0
186
- try:
187
- run_rate = round(runs / overs, 2) if overs > 0 else 0.0
188
- except (ZeroDivisionError, TypeError):
189
- run_rate = 0.0
206
+ run_rate = _run_rate(inn)
190
207
  innings_normalized.append(
191
208
  {
192
209
  "batting_team_id": str(inn["team"]["objectId"]),
@@ -4,10 +4,10 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "python-espncricinfo"
7
- version = "1.1.0"
7
+ version = "1.2.0"
8
8
  description = "Python client for ESPNcricinfo match, series, season, team and player data"
9
9
  readme = "README.md"
10
- requires-python = ">=3.12"
10
+ requires-python = ">=3.13"
11
11
  license = "MIT"
12
12
  license-files = ["LICENSE.txt"]
13
13
  keywords = [
@@ -26,17 +26,16 @@ classifiers = [
26
26
  "Operating System :: OS Independent",
27
27
  "Programming Language :: Python :: 3",
28
28
  "Programming Language :: Python :: 3 :: Only",
29
- "Programming Language :: Python :: 3.12",
30
29
  "Programming Language :: Python :: 3.13",
31
30
  "Programming Language :: Python :: 3.14",
32
31
  "Topic :: Internet :: WWW/HTTP",
33
32
  "Topic :: Software Development :: Libraries :: Python Modules",
34
33
  ]
35
34
  dependencies = [
36
- "requests",
37
- "beautifulsoup4",
38
- "dateparser",
39
- "lxml",
35
+ "requests>=2.32.2",
36
+ "beautifulsoup4>=4.12.3",
37
+ "dateparser>=1.2.1",
38
+ "lxml>=5.3.0",
40
39
  "playwright>=1.48.0",
41
40
  ]
42
41
 
@@ -46,7 +45,6 @@ email = "dwillis@gmail.com"
46
45
 
47
46
  [[project.authors]]
48
47
  name = "Gaurav Sood"
49
- email = "gsood07@gmail.com"
50
48
 
51
49
  [project.urls]
52
50
  Homepage = "https://github.com/outside-edge/python-espncricinfo"
@@ -76,7 +74,7 @@ test = [
76
74
 
77
75
  [tool.ruff]
78
76
  line-length = 88
79
- target-version = "py312"
77
+ target-version = "py313"
80
78
 
81
79
  [tool.ruff.lint]
82
80
  external = ["DOC"]
@@ -4,15 +4,15 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "python-espncricinfo"
7
- version = "1.1.0"
7
+ version = "1.2.0"
8
8
  description = "Python client for ESPNcricinfo match, series, season, team and player data"
9
9
  readme = "README.md"
10
- requires-python = ">=3.12"
10
+ requires-python = ">=3.13"
11
11
  license = "MIT"
12
12
  license-files = ["LICENSE.txt"]
13
13
  authors = [
14
14
  {name = "Derek Willis", email = "dwillis@gmail.com"},
15
- {name = "Gaurav Sood", email = "gsood07@gmail.com"},
15
+ {name = "Gaurav Sood"},
16
16
  ]
17
17
  keywords = ["espncricinfo", "cricket", "t20", "odi", "test cricket", "scorecard", "sports data"]
18
18
  classifiers = [
@@ -22,13 +22,12 @@ classifiers = [
22
22
  "Operating System :: OS Independent",
23
23
  "Programming Language :: Python :: 3",
24
24
  "Programming Language :: Python :: 3 :: Only",
25
- "Programming Language :: Python :: 3.12",
26
25
  "Programming Language :: Python :: 3.13",
27
26
  "Programming Language :: Python :: 3.14",
28
27
  "Topic :: Internet :: WWW/HTTP",
29
28
  "Topic :: Software Development :: Libraries :: Python Modules",
30
29
  ]
31
- dependencies = ["requests", "beautifulsoup4", "dateparser", "lxml", "playwright>=1.48.0"]
30
+ dependencies = ["requests>=2.32.2", "beautifulsoup4>=4.12.3", "dateparser>=1.2.1", "lxml>=5.3.0", "playwright>=1.48.0"]
32
31
 
33
32
  [project.urls]
34
33
  Homepage = "https://github.com/outside-edge/python-espncricinfo"
@@ -44,7 +43,7 @@ test = ["pytest>=8", "pytest-cov>=6"]
44
43
 
45
44
  [tool.ruff]
46
45
  line-length = 88
47
- target-version = "py312"
46
+ target-version = "py313"
48
47
 
49
48
  [tool.ruff.lint]
50
49
  external = ["DOC"]