Repository navigation
docs(foundation): restore Extractor._vfunc's annotation (#1839) - #1867
Conversation
- Uncomment the `_vfunc` annotation under its `#:` comment, so Sphinx attaches the description and the type the extraction page asks for. Typed `Callable[[Extractor, Any], Any]` rather than `VerboseHandler`, whose `Packet` union makes mypy reject the default and engine callbacks; mypy output on the extractor and the engines is unchanged. - Add a test that the comment attaches, read the way Sphinx's parser reads it, plus a cross-check against Sphinx itself where it is installed. Closes #1839
|
Verdict: GOOD TO GO at
|
|
The |
|
Understood: |
…1839) - Type `VerboseHandler` as `Callable[['Extractor', Packet], object]` and annotate `_vfunc` with it. The return is `object`, not `None`: every caller discards it, and `None` would make mypy reject a user callback that returns a value. - Narrow the frame to the engine's own packet type with `cast` inside the default callback and each engine's callback, so they accept the alias's `Packet` union. Runtime output is unchanged. - Pin the annotation and the alias's signature in the #1839 test. Refs #1839
|
Pushed The return is |
|
Correction to my comment above. The point still holds for real two-argument callbacks. A re-review measured |
- Replace `sys.stdout.write`, which takes one argument and so is no verbose callback at all, with `lambda e, f: sys.stdout.write(str(f))`: it takes the extractor and the frame and returns a value, so `object` accepts it where `None` would not. Refs #1839
|
Verdict: GOOD TO GO at
The one change was the NOTE's Non-blocking: |
|
For the typing, in that case, I think Any would be a better one for object. |
|
Understood. The callback's return type becomes A worker will change |
- Type `VerboseHandler`'s return as `Any` rather than `object`, per the owner's preference on #1867: every caller discards the result, and `Any` accepts any two-argument callback, whatever it returns. - Rewrite the NOTE above the alias to give that reason. - Pin `Any` in the signature test; the exact comparison still fails on a return of `None` or `object`. Refs #1839
|
Verdict: GOOD TO GO at
|
|
Coverage: 90.05% (unit tier, Python 3.15,
Per-file detail: the |
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the change. Narrow runs only, listed below.Added a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible: N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything else_vfuncannotation under its#:comment, so Sphinx attachesthe description and the type the extraction page asks for. Typed
Callable[[Extractor, Any], Any]rather thanVerboseHandler, whosePacketunion makes mypy reject the default and engine callbacks; mypyoutput on the extractor and the engines is unchanged.
it, plus a cross-check against Sphinx itself where it is installed.
Closes #1839