Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an API for passing plugins to the Coverage constructor #1919

Merged
merged 1 commit into from
Feb 16, 2025

Conversation

alex
Copy link
Contributor

@alex alex commented Jan 20, 2025

No description provided.

@alex
Copy link
Contributor Author

alex commented Jan 20, 2025

Hmm, what's the correct idiom for documenting TCoverageInit? I don't see the types.py types documented.

@nedbat
Copy link
Owner

nedbat commented Feb 9, 2025

I'll have to figure out what to do about the docs. It might be that we type it as Iterable[Callable] or something vague like that, with details in the English.

You made the passed list of plugins override the ones found in the config. Is there a reason for that? I would have thought it would be additive.

@alex
Copy link
Contributor Author

alex commented Feb 10, 2025

Sure, I can switch to bare Iterable[Callable], will do that tomorrow.

As for why override, I went with the first sentence in the Coverage docstring: "Many of these arguments duplicate and override values that can be provided in a configuration file."

If you have a preference for them being additive instead, happy to switch, I don't feel strongly.

@alex
Copy link
Contributor Author

alex commented Feb 15, 2025

@nedbat would you prefer I switch to adding, instead of replacing?

@nedbat
Copy link
Owner

nedbat commented Feb 16, 2025

You make a good case: "read Ned his own docs to show that I was right" :D

@nedbat nedbat merged commit ad7daf6 into nedbat:master Feb 16, 2025
32 checks passed
@alex alex deleted the plugins branch February 16, 2025 01:52
@alex
Copy link
Contributor Author

alex commented Feb 16, 2025

:D Thanks for the review and merge!

mod = sys.modules[module]
if plugin_override is not None:
for override in plugin_override:
override(plugins, {})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, after merging, thinking about documenting this, I have a hard time explaining why config options are passed to this function but they are always empty. I'm going to change the signature of the plugin function to leave it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! I went for consistency with the signature of plugin inits loaded from the config, but that did produce this slightly silly result.

nedbat added a commit that referenced this pull request Feb 16, 2025
nedbat added a commit that referenced this pull request Feb 16, 2025
Also simplify the callable signature for plugin overrides, since the
second config argument would always be empty.
@nedbat
Copy link
Owner

nedbat commented Mar 16, 2025

This is now released as part of coverage 7.7.0.

@alex
Copy link
Contributor Author

alex commented Mar 16, 2025

❤️ thanks!

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.

None yet

2 participants