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

Prevent plugin dependencies in "omit" from causing already-imported warnings #1044

Conversation

AlexCLeduc
Copy link

I came across the same bug noted in this comment when using django plugin alongside both source/include and omit would cause a bunch of already-imported warnings for the plugin's dependencies:

Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/__init__.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/engine.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/base.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/context.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/exceptions.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/library.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/utils.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/defaulttags.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/defaultfilters.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/smartif.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/templatetags/__init__.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/templatetags/i18n.py (already-imported)

I tried to fix this from the plugin side, but the only place the plugin gets an opinion is in the plugin's file_tracer() method, and we can't disable tracing for the core django templates, otherwise we can't trace the templates themselves.

Every other omit_match check is used too late, after plugins have already imported their dependencies

@codecov-io
Copy link

codecov-io commented Oct 17, 2020

Codecov Report

Merging #1044 into master will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1044      +/-   ##
==========================================
- Coverage   93.97%   93.95%   -0.03%     
==========================================
  Files         179      179              
  Lines       25140    25164      +24     
  Branches     2613     2615       +2     
==========================================
+ Hits        23626    23642      +16     
- Misses       1210     1218       +8     
  Partials      304      304              
Impacted Files Coverage Δ
coverage/inorout.py 74.07% <100.00%> (+0.29%) ⬆️
tests/test_plugins.py 99.25% <100.00%> (+0.01%) ⬆️
tests/test_debug.py 90.82% <0.00%> (-7.34%) ⬇️
test_plugins.py 98.76% <0.00%> (+0.02%) ⬆️
inorout.py 70.37% <0.00%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3274cba...42928bf. Read the comment docs.

@AlexCLeduc AlexCLeduc force-pushed the dont-warn-about-omitted-files-when-using-source-or-exclude branch from 42928bf to 8176aea Compare October 18, 2020 16:54
@AlexCLeduc AlexCLeduc changed the title Prevent plugin dependencies in "omit" from causing already-imported warnings (WIP) Prevent plugin dependencies in "omit" from causing already-imported warnings Oct 19, 2020
@AlexCLeduc AlexCLeduc marked this pull request as ready for review October 19, 2020 01:05
@nedbat
Copy link
Owner

nedbat commented Jan 17, 2021

Sorry, this has taken a while to get to. Thanks for providing a test! But I tried running the test without your fix, and it didn't fail. Does it fail for you?

@AlexCLeduc AlexCLeduc marked this pull request as draft February 8, 2021 01:16
@AlexCLeduc AlexCLeduc force-pushed the dont-warn-about-omitted-files-when-using-source-or-exclude branch from cbfffc4 to 278f54b Compare February 8, 2021 01:20
@AlexCLeduc
Copy link
Author

Sorry about that, I was probably blindly chasing coverage 😄

I've added a new failing test case, you can see it fail with the already-imported warning in CI https://github.com/nedbat/coveragepy/runs/1851303652#step:7:108

@AlexCLeduc AlexCLeduc marked this pull request as ready for review February 8, 2021 01:45
@nedbat
Copy link
Owner

nedbat commented May 1, 2021

Ugh, I'm sorry, I forgot you had fixed this problem. I fixed it in a different way for #1150. Does it solve the problem for you?

@ProsperousHeart
Copy link
Contributor

Since there has been no response, are we good to close this?

@AlexCLeduc
Copy link
Author

Apologies for keeping this open, if I recall correctly I think I had found a different workaround by changing which options I was using and forgot to test the new fix. I'll close now

@AlexCLeduc AlexCLeduc closed this Mar 20, 2023
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

4 participants