Skip to content

Treat inherited-annotated attributes as typed in pyrefly coverage#3999

Open
jorenham wants to merge 1 commit into
facebook:mainfrom
jorenham:gh-3997
Open

Treat inherited-annotated attributes as typed in pyrefly coverage#3999
jorenham wants to merge 1 commit into
facebook:mainfrom
jorenham:gh-3997

Conversation

@jorenham

Copy link
Copy Markdown
Contributor

Summary

A method-assigned attribute without its own annotation is no longer reported as untyped by pyrefly coverage {check, report} when a base class declares it:

class P_AttrList:
    attrs: dict[str, Any]

class DefaultStatement(P_AttrList):
    def __init__(self, attrs: dict[str, Any]) -> None:
        self.attrs = attrs  # was: untyped

It takes the type quality of the nearest base annotation, so dict[str, Any] is typed and a bare Any is any.

Fixes #3997

Test Plan

Regression tests added, and verified that check / report are still in sync

@github-actions

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coverage check reports inherited typed attribute as untyped

1 participant