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

Adding Branch Coverage to API #1888

Open
eleanorjboyd opened this issue Nov 5, 2024 · 0 comments · May be fixed by #1898
Open

Adding Branch Coverage to API #1888

eleanorjboyd opened this issue Nov 5, 2024 · 0 comments · May be fixed by #1898
Labels
enhancement New feature or request

Comments

@eleanorjboyd
Copy link

eleanorjboyd commented Nov 5, 2024

Hi! Eleanor from the Python for VS Code extension following up on API updates I was hoping to get which the VS Code python extension needs to support branch coverage! As you know, right now there is no way to get branch coverage from the API so Im looking to implement this but wanted to start the discussion as an issue to make sure I have the right approach.

What I think is the easiest access point to the branch coverage values I am looking for is in the Analysis class. Here there is the function _total_branches() which would provide one value I need and then I would need either covered branches or missing branches. n_missing_branches is defined in the Analysis class but not accessible, so maybe a getter for this value would be sufficient. (it is my understanding that branches are different from arcs and therefore it is not sufficient to display arc values but if I am mistaken please let me know)

Next is getting the Analysis class instance for a given file. From what I can tell, it seems like this is returned in two places, _analyze or analysis_from_file_reporter, (which makes sense given that _analyze calls analysis_from_file_reporter). It seems like _analyze under the Coverage class is probably easiest, given the comment "Private for now." in its docstring this might have been something already considered.

To summarize, what I am suggesting is:

  1. making the Analysis class part of the API
  2. adding the _analyze function in Coverage to the API
  3. adding a function to Analysis to surface either covered branches or missing branches

These are quite a few asks so if you have a suggestion that might add less to the API (and less to maintain) please let me know. It is not my intent to bloat the API only get these branch numbers so we could also attempt edits to surface them without the Analysis data class but I am unsure.

For context, here is where we collect and transform coverage in the extension. Here was my previous idea on how to get branch coverage before I realized it was not part of the API.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant