Skip to content

pyrefly coverage doesn't exclude the __init__ return slot when overloaded #4019

Description

@jorenham

Implicit dunder returns are excluded from the typable count even when annotated, but merge_overloads recomputes overload slots and only skips unannotated returns:

from typing import overload

class Plain:
    def __init__(self, x: int) -> None: ...

class Overloaded:
    @overload
    def __init__(self, x: int) -> None: ...
    @overload
    def __init__(self, x: str) -> None: ...
    def __init__(self, x): ...

pyrefly coverage report:

{"name": "Plain.__init__", "n_typable": 1, "n_typed": 1}
{"name": "Overloaded.__init__", "n_typable": 2, "n_typed": 2}

Both should have only 1 typable (the x parameter), because the __init__ return type (viz. None) is trivial, so there's no utility in annotating it.

Metadata

Metadata

Assignees

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