Skip to content

pyrefly report: For stubs-only packages, is the source package taken into account? #3105

@jorenham

Description

@jorenham

For example:

# pkg/__init__.py
spam: str = "ham"
ham: int = 42
# pkg-stubs/__init__.pyi
ham: int

Running typestats check pkg-stubs (or typestats report pkg-stubs) will report 50% coverage, because spam is missing in the stubs, and type-checkers will therefore not know that it's there (because they'll only look at the .pyi here, following the typing spec, so the annotation of spam in the .py will not be "seen").

Will pyrefly report report 100% or 50% coverage?
I.e., does pyrefly report combines the symbol tree of both pkg and pkg- packages, or does it only index the .pyi?

I realize this is a bit paradoxical, because type-checkers ignore a .py if there's also a corresponding .pyi.
But we're measuring type coverage, so we can't assume that a .pyi is always complete.

Relevant typestats docs: https://jorenham.github.io/typestats/reference/implementation/#stubs-overlay-merge

Assuming that pyrefly currently doesn't do this, we could also do this manually in typestats by running pyrefly report on both pkg and pkg-stubs. But I can imagine that this combined approach can be useful outside of typestats too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions