Skip to content

fix(web): export web API and lazy-load pospider#165

Open
muxia0396 wants to merge 1 commit into
CoderWanFeng:developfrom
muxia0396:fix/export-web-api
Open

fix(web): export web API and lazy-load pospider#165
muxia0396 wants to merge 1 commit into
CoderWanFeng:developfrom
muxia0396:fix/export-web-api

Conversation

@muxia0396

Copy link
Copy Markdown

Summary

  • export office.web from the top-level office package
  • lazy-load pospider so an optional dependency does not break import office
  • preserve internal dependency import errors while providing clear messages for a missing or incompatible pospider
  • replace the live-network web test with deterministic delegation and compatibility tests

Why

office/api/web.py already defines url2ebook(), and the repository example calls office.web.url2ebook(...), but office/__init__.py does not export web. As a result, the documented top-level usage raises AttributeError.

Importing pospider at module load time would also make the entire office package fail to import when that optional package is unavailable. The published pospider 0.0.1 package currently does not expose the expected url.url2ebook API, so the loader now reports that incompatibility explicitly instead of leaking an unclear attribute error.

Impact

Users can access the web namespace consistently through office.web. Environments that do not use web conversion can still import office without installing pospider, while callers receive actionable errors when the dependency is missing or incompatible.

Validation

python -m unittest tests.test_code.test_optional_imports tests.test_code.test_web -v

All 5 related tests pass.

@muxia0396
muxia0396 marked this pull request as ready for review July 15, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant