-
-
Notifications
You must be signed in to change notification settings - Fork 438
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
3.14 field annotation not covered #1908
Comments
This definitely is because of deferred annotations. I'm not sure what to do here. The fact is there is code that has not been run. But also, it is likely never to be run, and it's fine that it isn't run. But it can have errors. This will be an error if you run it in 3.13: class X:
x: inttttt
y = 1
In 3.14, it won't error, but it will if you try to get the annotation: class X:
x: inttttt
y = 1
from annotationlib import get_annotations, Format
get_annotations(X, format=Format.VALUE)
|
btw, I also opened a discussion thread about this: https://discuss.python.org/t/how-should-coverage-py-treat-deferred-annotations/74990 |
As a user, my feeling is that if the field annotation is considered covered in 3.13 with Here is a naive suggestion. I assume there is a line somewhere to the effect of: if has_future_annotations_import():
field_annotation.count_as_covered() Maybe that could be changed to: if has_future_annotations_import() or PY_VER_314_PLUS:
field_annotation.count_as_covered() |
All of the annotations are put into code objects called |
Tested; works. Thanks! |
This is now released as part of coverage 7.6.10. |
The following snippet gets counted as 100% coverage under 3.13 and earlier versions, but under 3.14 it is counted as having a missing line:
Adding
from __future__ import annotations
causes everything to be counted:Could have something to do with https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-pep649?
The text was updated successfully, but these errors were encountered: