Skip to content

pyrefly coverage check --public-only: --project-excludes shouldn't exclude public re-exports #4034

Description

@MarcoGorelli

Here's a project I have

foo/__init__.py

from foo._something_private import bar

__all__ = ['bar']

foo/_something_private.py

def bar(a) -> None:
    return None

So, foo._something_private.bar is defined in a private file, but it's re-exported in a public place (foo/__init__.py).

And indeed, pyrefly coverage check foo --public-only correctly checks foo._something_private.bar

$ pyrefly coverage check foo --public-only
 WARN `foo._something_private.bar` is not fully typed [coverage-partial]
 --> foo/_something_private.py:1:1
  |
1 | / def bar(a) -> None:
2 | |     return None
  | |_______________-
  |
ERROR type coverage 50.00% (1 of 2 typable) is below the 100.00% threshold

But, here's the issue: if I use --project-excludes=foo/_something_private.py, then foo._something_private.bar gets excluded, even though it's re-exported in a public place:

$ pyrefly coverage check foo --public-only --project-excludes foo/_something_private.py
 INFO type coverage 100.00% (0 of 0 typable)

I'd like to suggest one of the following as a solution:

  • --project-excludes doesn't exclude publicly re-exported symbols. I think I'd prefer this solution
  • or, pyrefly coverage report shows all the re-exported paths, so then I can parse these as a user as I wish

Note that pyright shows foo.bar as the path for this symbol:

            {
                "category": "function",
                "name": "foo.bar",
                "referenceCount": 1,
                "isExported": true,
                "isTypeKnown": false,
                "isTypeAmbiguous": false,

Metadata

Metadata

Assignees

No one assigned

    Labels

    coverageIssues related to `pyrefly coverage`, `pyrefly report`quansight

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions