python / python/cpython

-m trace --count missing lines

Open
#142,867 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:
def x() -> tuple[
        int,
]:
    return (1, 'fred')

x()

python 3.13 (good):

xju@xjutv:~/tmp$ python3 --version
Python 3.13.1
xju@xjutv:~/tmp$ rm -f xxx.cover
xju@xjutv:~/tmp$ python3 -m trace --count -m xxx.py
xju@xjutv:~/tmp$ cat xxx.cover
    2: def x() -> tuple[
    1:         int,
       ]:
    1:     return (1, 'fred')
       
    1: x()

python 3.14 (bad):

xju@xjutv:~/tmp$ python3 --version
Python 3.14.2
xju@xjutv:~/tmp$ rm -f xxx.cover
xju@xjutv:~/tmp$ python3 -m trace --count -m xxx.py
xju@xjutv:~/tmp$ cat xxx.cover
    1: def x() -> tuple[
>>>>>>         int,
       ]:
    1:     return (1, 'fred')
       
    1: x()

... trace._get_executable_linenos returns the same in both 3.13 and 3.14; seems that Trace.run does not see that the type hint is "executed"? Could equally have trace._get_executable_linenos not report the type hint... they just need to agree.

Above is about the simplest example I came up with, but similar disagreement with class attribute hints like:

class X:
  a: int

... a: int is reported as "not covered".

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs
  • gh-143161

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the discrepancy with the Python snippet and compare the 3.13 and 3.14 coverage output. Inspect trace.Trace.run and trace._get_executable_linenos, which the report identifies as disagreeing about executed annotations. Done means both paths agree and type-hint lines, including class attribute hints, receive consistent coverage results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.