GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Specialised-self overloads select the first match for a gradual receiver · Issue #5205 · pyrefly-org/pyrefly

Specialised-self overloads select the first match for a gradual receiver #5205

New issue
Copy link
New issue
Copy link
Open
Bug
Open
Specialised-self overloads select the first match for a gradual receiver#5205
Bug
Copy link
Labels
overloads

Description

@cmp0xff
cmp0xff
opened on Oct 12, 2026
Issue body actions

Describe the Bug

Pyrefly 1.3.2 and 1.4.0.dev3 select the first specialised-self overload for Container[Any], but infer Unknown for the equivalent ordinary function. This reproduces with and without --spec-compliant-overloads=true.

from typing import Any, Generic, TypeVar, overload, reveal_type

T = TypeVar("T")


class Container(Generic[T]):
    @overload
    def scalar(self: "Container[int]") -> int: ...
    @overload
    def scalar(self: "Container[str]") -> str: ...
    def scalar(self) -> int | str:
        raise NotImplementedError

@overload
def scalar(value: Container[int]) -> int: ...
@overload
def scalar(value: Container[str]) -> str: ...
def scalar(value: Container[Any]) -> int | str:
    raise NotImplementedError


def probe(gradual: Container[Any]) -> None:
    reveal_type(gradual.scalar())  # int
    reveal_type(scalar(gradual))   # Unknown

Python: 3.12

Expected: handle receiver ambiguity consistently with explicit arguments,
per overload Step 5: https://typing.python.org/en/latest/spec/overload.html#step-5

Reversing the method overloads changes its result to str; concrete receivers remain precise.

  • Nightly mypy 2.5.0+dev (Handle overloaded method ambiguity caused by self-types python/mypy#22011) and Pyright 1.1.414 infer Any for both calls
  • Ty 0.0.85 infers Unknown (overloads resolved as a conflict with Any astral-sh/ty#4055)

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.pZUxD4IwEIX_SiMDuNCdycTJxTjgpA5VGzRqawD17_sO2lqqEokbIXevd-1974ZapvNF511fjShHwSYqWY_y9ah5PEvhVKsaDcgyMZKrfGOnb2I1X1BVO3GGDkGV4Rpc9gpPvoE0DRo-M5am6XCRxiBaEXx6IkGWPQYwUlyIwlzXM7KWi1R4XweFV4mnZ-judhL08WMmlR8U3xeOh3QHdTrp7aLVvJZ6K5OiFPubOH8U9XD3BsKmpKao8ZixiAp4jzQRJoECEblUJ6UfNPYBdBFbtD-YmV-sG9Ba3LDUQCGuIsI-k-xQ19cq49ym67LgUvG93lW8k8EZ-Yu4i2OzKrtyTDcmUUH2H9rjFva4j_WYUEdEL75P

(Only applicable for extension issues) IDE Information

No response

Reacted by Joren Hammudoglu

Activity

  1. cmp0xff commented on Oct 14, 2026

    @cmp0xff
    cmp0xff
    on Oct 14, 2026
    Author
    More actions

    It seems that ty and pyright are both moving in this direction astral-sh/ruff#29342 microsoft/pyright#11864

    Reacted by Joren Hammudoglu
  2. rchen152
    added
    overloads
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    overloads

    Type

    Bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.