Skip to content

Commit 343a9bb

Browse files
committed
Merge remote-tracking branch 'origin/main' into rel-118-fix
# Conflicts: # CHANGELOG.md
2 parents cd68338 + 79f3b8d commit 343a9bb

14 files changed

Lines changed: 235 additions & 36 deletions

‎.github/workflows/github-pages.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
persist-credentials: false
3131

3232
- name: Set up Python
33-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
33+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
3434
with:
3535
python-version: "3.12"
3636

‎.github/workflows/live-tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
persist-credentials: false
3232

3333
- name: Set up Python
34-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
34+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
3535
with:
3636
python-version: "3.12"
3737

‎.github/workflows/publish.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
persist-credentials: false
2424

2525
- name: Set up Python
26-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
26+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
2727
with:
2828
python-version: "3.12"
2929

@@ -153,7 +153,7 @@ jobs:
153153
sha256sum -c artifact.sha256
154154
155155
- name: Publish exact verified distributions
156-
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1 2026-07-28
156+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 2026-10-20
157157
with:
158158
packages-dir: ${{ runner.temp }}/release-artifact/dist/
159159
skip-existing: true

‎.github/workflows/test.yml‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@ permissions:
1212
jobs:
1313
test:
1414
name: Test (Python ${{ matrix.python-version }})
15-
runs-on: ubuntu-latest
15+
# Pinned: ubuntu-latest is now Ubuntu 26.04, where actions/setup-python
16+
# has no 3.8/3.9 builds (#165). requires-python is still >=3.8, so keep
17+
# testing those versions on 24.04 until support is dropped deliberately.
18+
runs-on: ubuntu-24.04
1619
timeout-minutes: 20
1720
strategy:
1821
fail-fast: false
1922
matrix:
20-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
23+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
2124

2225
steps:
2326
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
2427
with:
2528
persist-credentials: false
2629

2730
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
31+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
2932
with:
3033
python-version: ${{ matrix.python-version }}
3134

‎.github/workflows/weekly-health.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
persist-credentials: false
2828

2929
- name: Set up Python
30-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
30+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
3131
with:
3232
python-version: "3.12"
3333

‎CHANGELOG.md‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@ All notable changes to the OilPriceAPI Python SDK will be documented in this fil
44

55
## [Unreleased]
66

7-
## [1.18.0] - 2026-11-16
7+
## [1.18.0] - 2026-11-15
8+
9+
### Changed
10+
11+
- **Dropped Python 3.8 and 3.9 support.** Both versions are end-of-life (Python 3.8
12+
reached EOL in October 2024, Python 3.9 in October 2025) and are no longer
13+
available on the latest Ubuntu GitHub Actions runners (ubuntu-26.04). The package
14+
now requires Python 3.10 or later. Added support for Python 3.13 and 3.14 in CI.
15+
- Updated `requires-python` from `>=3.8` to `>=3.10` in `pyproject.toml`
16+
- Removed Python 3.8 and 3.9 classifiers, added 3.13 and 3.14 classifiers
17+
- Removed conditional `typing-extensions` dependency (only needed for Python < 3.10)
18+
- Updated tool configuration targets (black, ruff, mypy) to reflect the new minimum
819

920
### Fixed
1021

‎oilpriceapi/async_client.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ async def get_multiple(
541541
prices = []
542542
failures = []
543543

544-
for chunk, result in zip(chunks, results):
544+
for chunk, result in zip(chunks, results, strict=False):
545545
if isinstance(result, list):
546546
prices.extend(result)
547547
continue
@@ -552,7 +552,7 @@ async def get_multiple(
552552
retry = await asyncio.gather(
553553
*(self.get(code) for code in chunk), return_exceptions=True
554554
)
555-
for code, item in zip(chunk, retry):
555+
for code, item in zip(chunk, retry, strict=False):
556556
if isinstance(item, Price):
557557
prices.append(item)
558558
else:

‎oilpriceapi/cli.py‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ def _get_client():
4444
return OilPriceAPI(api_key=api_key)
4545

4646

47+
def _print_error(error):
48+
"""Print an API error and, when the API sent one, the link that resolves it.
49+
50+
A plan refusal (HTTP 402/403, e.g. history on a free account) is not a
51+
failure the user can retry; it needs the upgrade link the API returned.
52+
"""
53+
console.print(f"[red]Error:[/red] {error}")
54+
status = getattr(error, "status_code", None)
55+
url = getattr(error, "remediation_url", None)
56+
if status in (402, 403):
57+
# Only the history gate leaves latest prices available. A quota 402
58+
# (free_tier_quota_exceeded) refuses /v1/prices/latest as well.
59+
if getattr(error, "code", None) == "UPGRADE_REQUIRED":
60+
console.print("Latest prices still work: oilprice price BRENT_CRUDE_USD")
61+
if url:
62+
# soft_wrap keeps the URL on one line so it can be copied.
63+
console.print(f"Upgrade: {url}", soft_wrap=True, markup=False)
64+
65+
4766
@click.group()
4867
@click.version_option(version=__version__, prog_name="oilprice")
4968
def main():
@@ -125,7 +144,7 @@ def historical(commodity, days, as_json):
125144
end_date=end.strftime("%Y-%m-%d"),
126145
)
127146
except Exception as e:
128-
console.print(f"[red]Error:[/red] {e}")
147+
_print_error(e)
129148
sys.exit(1)
130149

131150
prices = result.data if hasattr(result, "data") else result

‎oilpriceapi/exceptions.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,10 @@ def error_from_response(
599599
"remediation_url",
600600
"upgrade_url",
601601
"action_url",
602-
),
602+
)
603+
# The historical-access 402 (UPGRADE_REQUIRED) nests its link as
604+
# ``upgrade.url`` and sends no top-level ``upgrade_url``.
605+
or _first_value([_mapping(_first_value(sources, "upgrade"))], "url"),
603606
"retry_metadata": retry_metadata,
604607
"raw_body": raw_body,
605608
"raw_text": raw_text,

‎oilpriceapi/visualization.py‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,21 +452,19 @@ def create_small_multiples(
452452
fig, axes = plt.subplots(
453453
rows, cols,
454454
figsize=(12, 3 * rows),
455-
dpi=100
455+
dpi=100,
456+
# Always a 2-D grid, so axes[row][col] works for one row or one
457+
# column too (#158).
458+
squeeze=False
456459
)
457460

458-
if rows == 1:
459-
axes = [axes]
460-
if cols == 1:
461-
axes = [[ax] for ax in axes]
462-
463461
end_date = datetime.now()
464462
start_date = end_date - timedelta(days=days)
465463

466464
for idx, commodity in enumerate(commodities):
467465
row = idx // cols
468466
col = idx % cols
469-
ax = axes[row][col] if rows > 1 else axes[col]
467+
ax = axes[row][col]
470468

471469
# Fetch data
472470
history = self.client.historical.get(
@@ -508,7 +506,7 @@ def create_small_multiples(
508506
for idx in range(n, rows * cols):
509507
row = idx // cols
510508
col = idx % cols
511-
ax = axes[row][col] if rows > 1 else axes[col]
509+
ax = axes[row][col]
512510
ax.axis('off')
513511

514512
# Add overall title and source

0 commit comments

Comments
 (0)