Repository navigation
fix: lazy visualizer so client construction never warns (#151); remove root clutter - #157
Conversation
…151) OilPriceAPI.__init__ built PriceVisualizer eagerly, which imported matplotlib when present and emitted ImportWarning when absent, so `python -W error` could not construct a client. `viz` is now a property that builds on first access and returns None without matplotlib (unchanged contract for `if not client.viz`). Plotting methods still raise ImportError with guidance. Also removes root clutter: test_debug_params.py (an ad-hoc live-call debug script, not a test; pytest testpaths is tests/) and WEBSITE_FIXES_DEPLOYED.md (a 2025-11 website deploy note). Closes #151 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QQ7W3CkRKEnBpU5KRQUfUu
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Adversarial review: BLOCK (head c4192a9)Blocking: this PR makes the no-matplotlib failure unexplained. I tested in a fresh venv with the SDK installed and matplotlib not installed: On Suggested fix (keeps #151's goal): in the Confirmed working:
|
…otlib (#151) Adversarial review of #157 found client.viz returned None when matplotlib was missing, so client.viz.plot_* failed with a bare AttributeError. The viz property now always builds a cached PriceVisualizer lazily (no import, no warning at construction), and each plotting method raises ImportError: "matplotlib is required for visualization. Install it with: pip install 'oilpriceapi[viz]'". Adds the viz extra to pyproject. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QQ7W3CkRKEnBpU5KRQUfUu
Addressed the BLOCK on c4192a9 (new head 2a7596e)The review found that without matplotlib, Changes
Evidence
|
Adversarial review: APPROVE (head 2a7596e)I re-reviewed head Prior BLOCK point (
With the extra installed: In a second fresh venv I ran Wheel metadata ( The base Tests and lint (Python 3.12 venv with all extras):
Non-blocking:
|
* chore(deps): bump actions/download-artifact from 8.0.1 to 8.0.2 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 8.0.1 to 8.0.2. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@3e5f45b...9000827) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: 8.0.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * fix: lazy visualizer so client construction never warns (#151); remove root clutter (#157) * fix: build the visualizer lazily so client construction never warns (#151) OilPriceAPI.__init__ built PriceVisualizer eagerly, which imported matplotlib when present and emitted ImportWarning when absent, so `python -W error` could not construct a client. `viz` is now a property that builds on first access and returns None without matplotlib (unchanged contract for `if not client.viz`). Plotting methods still raise ImportError with guidance. Also removes root clutter: test_debug_params.py (an ad-hoc live-call debug script, not a test; pytest testpaths is tests/) and WEBSITE_FIXES_DEPLOYED.md (a 2025-11 website deploy note). Closes #151 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QQ7W3CkRKEnBpU5KRQUfUu * fix: client.viz raises ImportError naming the viz extra without matplotlib (#151) Adversarial review of #157 found client.viz returned None when matplotlib was missing, so client.viz.plot_* failed with a bare AttributeError. The viz property now always builds a cached PriceVisualizer lazily (no import, no warning at construction), and each plotting method raises ImportError: "matplotlib is required for visualization. Install it with: pip install 'oilpriceapi[viz]'". Adds the viz extra to pyproject. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QQ7W3CkRKEnBpU5KRQUfUu --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * test: verify the updated artifact action pin --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: karlwaldman <karl.waldman@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Closes #151.
Problem
python -W error -c "import oilpriceapi; oilpriceapi.OilPriceAPI(api_key='x')"on main 5d9aa37 without matplotlib ->ImportWarning: matplotlib is required for visualization(raised as error). Cause:OilPriceAPI.__init__buildsPriceVisualizereagerly and its__init__warns.Change
client.vizis a property: buildsPriceVisualizeron first access, returnsNonewhen matplotlib is missing (same contract the examples use:if not client.viz).PriceVisualizer.__init__no longer warns; plotting methods already raiseImportError.test_debug_params.py(ad-hoc live-call debug script outsidetestpaths) andWEBSITE_FIXES_DEPLOYED.md(2025-11 website deploy note). No references to either in the repo.Verification (local, Python venv)
client.vizis aPriceVisualizer; matplotlib not imported at construction; unit + new tests 1903 passed.Expected effect: SDK users who run with warnings-as-errors (pytest
filterwarnings=error,-W error) can construct a client; construction no longer pays the matplotlib import cost.🤖 Generated with Claude Code
https://claude.ai/code/session_01QQ7W3CkRKEnBpU5KRQUfUu