Skip to content

fix(vendor): exit on one line without the vendor extra (#1850) - #1875

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1850-vendor-cli-missing-extra
Oct 17, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1850-vendor-cli-missing-extra

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

  • pcapkit/vendor: record requests/beautifulsoup4 that fail to import in
    _MISSING and import no crawler while it is not empty; a PEP 562
    __getattr__ then raises ModuleNotFoundError for any crawler name or
    Vendor, naming the missing packages and pypcapkit[vendor]. The
    [socks]/[html5lib] extras stay warnings.
  • vendor/main: main() writes that message as one stderr line and
    returns 1 before any target runs, instead of the console script and
    python -m pcapkit.vendor dying with a traceback; --help and
    --version work without the extra.
  • docs and docstrings: versionchanged 1.5.0 for the package and the CLI.
  • tests/vendor: subprocess regression tests with the packages blocked;
    comments that described the old unconditional import are updated.

Closes #1850

- pcapkit/vendor: record requests/beautifulsoup4 that fail to import in
  `_MISSING` and import no crawler while it is not empty; a PEP 562
  `__getattr__` then raises ModuleNotFoundError for any crawler name or
  `Vendor`, naming the missing packages and `pypcapkit[vendor]`. The
  `[socks]`/`[html5lib]` extras stay warnings.
- vendor/__main__: `main()` writes that message as one stderr line and
  returns 1 before any target runs, instead of the console script and
  `python -m pcapkit.vendor` dying with a traceback; `--help` and
  `--version` work without the extra.
- docs and docstrings: versionchanged 1.5.0 for the package and the CLI.
- tests/vendor: subprocess regression tests with the packages blocked;
  comments that described the old unconditional import are updated.

Closes #1850
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 17, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at b2e54d9f5. A Sonnet cross-review tried to falsify each claim and none broke.

  • CLI without the extra. With requests and bs4 blocked, pcapkit-vendor prints one line naming the missing distributions and the extra, then exits 1 with no traceback. I reproduced this myself. Blocking only one of the two names only that one. --help and --version still work.
  • Library without the extra. import pcapkit.vendor succeeds. Crawler names raise ModuleNotFoundError with the same message, an unknown name raises a plain AttributeError, and dir, pydoc and reload all work.
  • With the extra installed. __all__ and the --help output are identical to base.
  • conda _extern. In a simulated tree where the dependencies resolve only from pcapkit/_extern, nothing is reported missing. Without _extern the CLI exits with the one-line message. A real conda build was not run.
  • Fail-before. With the old __init__.py/__main__.py, the new tests fail for the right reasons (a traceback in stderr, no _MISSING). The edited test files differ from base only in docstrings and comments.
  • Notes, not blockers:
    • hasattr(pcapkit.vendor, 'EtherType') raises rather than returning False while the extra is missing.
    • The module-level import typing exposes pcapkit.vendor.typing; a TYPE_CHECKING import would avoid that.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 17, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 90.06% (unit tier, Python 3.15, b2e54d9f5, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 2 20 2 96.77%
pcapkit/const 19595 881 2618 867 92.11%
pcapkit/corekit 2462 69 780 35 96.55%
pcapkit/dumpkit 276 3 100 3 98.40%
pcapkit/foundation 2915 164 1016 34 93.59%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17406 224 4580 189 98.10%
pcapkit/toolkit 872 177 298 8 77.18%
pcapkit/utilities 512 2 158 4 99.10%
pcapkit/vendor 4429 2341 1018 156 43.62%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 44ed96f into main Oct 17, 2026
57 checks passed
@JarryShaw
JarryShaw deleted the fix/1850-vendor-cli-missing-extra branch October 17, 2026 04:12
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 17, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(vendor): pcapkit-vendor fails with a bare ModuleNotFoundError without the vendor extra, which conda users cannot install

1 participant