Skip to content

fix(plugins): accept reports/options in diff_cover_report_quality hookspec - #613

Merged
Bachmann1234 merged 3 commits into
Bachmann1234:mainfrom
Sanjays2402:fix/plugin-hookspec-args
Aug 7, 2026
Merged

fix(plugins): accept reports/options in diff_cover_report_quality hookspec#613
Bachmann1234 merged 3 commits into
Bachmann1234:mainfrom
Sanjays2402:fix/plugin-hookspec-args

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Closes #549

The diff_cover_report_quality hookspec declared no parameters, but diff_quality_tool calls the plugin factory with reports=/options=. So a plugin that declares them fails pluggy validation (PluginValidationError), and one that declares none — the form shown in the README — fails at call time with TypeError: got an unexpected keyword argument 'reports'.

The hookspec now declares both arguments, and the factory is called with only the arguments its signature actually accepts, so the documented zero-argument plugin keeps working.

…kspec

The diff_cover_report_quality hookspec declared no parameters, but
diff_quality_tool called the plugin factory with reports= and options=.
A plugin declaring those arguments failed pluggy validation with
PluginValidationError, while one declaring none failed at call time with
TypeError: unexpected keyword argument 'reports'.

The hookspec now declares both arguments, and the factory is invoked with
only the arguments its signature actually accepts, so the zero-argument
plugin form documented in the README keeps working.

Closes Bachmann1234#549
@Bachmann1234

Copy link
Copy Markdown
Owner

Thanks for the pr! I'll look at this some point soon but it will be a little bit. If you don't hear back in a week feel free to ping me

@Sanjays2402

Copy link
Copy Markdown
Contributor Author

@Bachmann1234 taking you up on the ping offer - it's been about a week.

No changes since you last looked: still CLEAN/mergeable against main and all 14 checks are green. The change is confined to diff_cover/hookspecs.py (declare reports/options on diff_cover_report_quality) and diff_quality_tool.py (call the factory with only the params its signature accepts), so the zero-arg plugin form in the README keeps working while a plugin that declares the arguments no longer trips pluggy validation.

Happy to rebase or adjust the approach if you'd rather solve #549 a different way.

@Bachmann1234

Copy link
Copy Markdown
Owner

@Sanjays2402 Thanks for the reminder! For this one I think the readme needs to be updated and can you look at the pylint warnings?

@Sanjays2402

Copy link
Copy Markdown
Contributor Author

Both done, plus a merge of main to clear the conflict that had shown up in the meantime.

README: the plugin section now documents that the hook takes reports (the open handles for reports passed on the command line) and options (the --options string), that you only get the arguments you declare, and shows the two-argument form alongside the existing zero-argument example.

Pylint: was 9.83 on the three touched files. hookspecs.py had two unused-argument warnings - the hookspec body is just a docstring, so the arguments are unused by construction there; added a # pylint: disable=unused-argument on the signature. The test had an import-outside-toplevel for _call_reporter_factory, which was pointless, so it moved up to the module imports. Now 9.96, the only thing left being the pre-existing too-many-positional-arguments on generate_quality_report, which is on main too and I left alone.

tests/test_diff_quality_main.py is 19 passed and black is clean. The merge conflict was just my new tests landing next to your test_parse_format_from_config_file; both are kept.

@Bachmann1234

Copy link
Copy Markdown
Owner

alright, lets merge this in. I think ill be able to do a release tonight. Thanks for the pr!

@Bachmann1234
Bachmann1234 merged commit 3fdbf40 into Bachmann1234:main Aug 7, 2026
14 checks passed
@Bachmann1234

Copy link
Copy Markdown
Owner

Out in https://pypi.org/project/diff-cover/10.4.2/ ! Thanks again!

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.

Plugins are being given options that aren't in hookspec; plugin guide example fails

2 participants