count bare annotations as typed in pyrefly report #3172#3173
count bare annotations as typed in pyrefly report #3172#3173jorenham wants to merge 2 commits intofacebook:mainfrom
pyrefly report #3172#3173Conversation
This comment has been minimized.
This comment has been minimized.
connernilsen
left a comment
There was a problem hiding this comment.
I think this is good. I'll bring it in and see if there are comments internally
|
Actually could you rebase first @jorenham? Then I'll pull it in. Just re-request a review from me |
connernilsen
left a comment
There was a problem hiding this comment.
rebase + two other things I found on an extra pass
| .and_then(|awt| awt.annotation.ty.as_ref().map(Self::is_type_known)) | ||
| }); | ||
| let slots = | ||
| Self::classify_slot(resolved_ty.or(annotation_text.is_some().then_some(true))); |
There was a problem hiding this comment.
Should we check the annotation text here to be sure it's a Final? Would this classify something else like value: Callable as typed, even when its parameters are empty?
There was a problem hiding this comment.
I think it's ok for a _: Callable to count as typed, as it's equivalent to _: Callable[..., Any]. Because the idea behind n_any only counting things that resolve to _: Any (in typestats at least) is that this is equivalent to _, i.e. no type annotation at all.
Final as typed in pyrefly report #3172pyrefly report #3172
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Summary
This changes
typestats reportso that it will treat e.g. bareFinalattrs and_: listas typed instead of any, in line with typestats.Fixes #3172
Test Plan
Added unit tests and integration tests