Skip to content

attrs 21.3.0 breaks coverage report on Python 3.6 (regression from 21.2.0) #895

Closed

Description

@andersk

With attrs 21.3.0, if I run a script that does import attr using coverage, I get an error from coverage report.

$ python3 --version
Python 3.6.15
$ echo 'import attr' > test.py
$ pip3 install attrs coverage
…
Successfully installed attrs-21.3.0 coverage-6.2
$ coverage run test.py
$ coverage report
No source for code: '/tmp/rep-1>'.

This worked with attrs 21.2.0.

$ pip3 install attrs==21.2.0
…
Successfully installed attrs-21.2.0
$ coverage run test.py
$ coverage report
Name      Stmts   Miss  Cover
-----------------------------
test.py       1      0   100%
-----------------------------
TOTAL         1      0   100%

I bisected the problem to commit 5a368d8 (#858). Cc @thetorpedodog @hynek.

Activity

  1. Tinche commented on Dec 29, 2021

    @Tinche
    Member

    Interesting. Could be a coverage bug? Not sure why this would break it.

  2. deadlylaid commented on Dec 29, 2021

    @deadlylaid

    python 3.7 has same issue

    working in CI/CD

    Running with gitlab-runner 14.6.0~beta.71.gf035ecbf (f035ecbf)
      on green-5.shared.runners-manager.gitlab.com/default xS6Vzpvo
    Preparing the "docker+machine" executor
    Using Docker executor with image python:3.7-slim-buster ...
    Pulling docker image python:3.7-slim-buster ...
    
    [...]
    
    Collecting attrs>=19.2.0
      Downloading attrs-21.3.0-py2.py3-none-any.whl (61 kB)
    [...]
    
    coverage report -i
    /usr/local/lib/python3.7/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/builds/Jade/jade/jadeapp/jade-rest-auth/rep-10>': No source for code: '/builds/Jade/jade/jadeapp/jade-rest-auth/rep-10>'. (couldnt-parse)
      coverage._warn(msg, slug="couldnt-parse")
    /usr/local/lib/python3.7/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/builds/Jade/jade/jadeapp/jade-rest-auth/rep-11>': No source for code: '/builds/Jade/jade/jadeapp/jade-rest-auth/rep-11>'. (couldnt-parse)
      coverage._warn(msg, slug="couldnt-parse")
    /usr/local/lib/python3.7/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/builds/Jade/jade/jadeapp/jade-rest-auth/rep-12>': No source for code: '/builds/Jade/jade/jadeapp/jade-rest-auth/rep-12>'. (couldnt-parse)
      coverage._warn(msg, slug="couldnt-parse")
    /usr/local/lib/python3.7/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/builds/Jade/jade/jadeapp/jade-rest-auth/rep-13>': No source for code: '/builds/Jade/jade/jadeapp/jade-rest-auth/rep-13>'. (couldnt-parse)
    
    [...]
    
    coverage xml
    No source for code: '/builds/DeepNatural/deepnaturalai/deepapi/deepapi-rest-auth/rep-10>'.
    make: *** [Makefile:37: coverage] Error 1
    

    but when i fixed attrs==21.2.0, its work

  3. hynek commented on Dec 29, 2021

    @hynek
    Member

    @nedbat any idea? 🤔

  4. hynek commented on Dec 29, 2021

    @hynek
    Member

    OK, I think I've got it. Could y'all have a look at #896 and tell me if it fixes your problems? I can cut a release later today if yes.

  5. hynek commented on Dec 29, 2021

    @hynek
    Member

    JFTR: the reason why it didn't come up in my own tests is because I always set a --source:

    $ coverage run test.py; coverage report
    No source for code: '/Users/hynek/tmp/rep-1>'.
    $ coverage run --source test test.py; coverage report
    Name      Stmts   Miss  Cover
    -----------------------------
    test.py       1      0   100%
    -----------------------------
    TOTAL         1      0   100%
  6. andersk commented on Dec 29, 2021

    @andersk
    Author

    Yeah, #896 works for me, both in my minimal test case and in my actual application (Zulip). Thanks for the quick fix!

  7. hynek commented on Dec 29, 2021

    @hynek
    Member

    Thank you for the quick confirmation!

  8. hynek commented on Dec 29, 2021

    @hynek
    Member

    21.4 is on PyPI – sorry for the regression and hope it's fixed now.

  9. added a commit that references this issue on Jan 6, 2022
  10. added a commit that references this issue on Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions