Skip to content

inconsistent-overload-default false positive #2869

@grievejia

Description

@grievejia

Describe the Bug

Minimal repro:

from typing import overload, Literal

@overload
def parse_target(name_only: Literal[True] = ...) -> str: ...  # pyrefly FP
@overload
def parse_target(name_only: bool = ...) -> str | list[str]: ...
def parse_target(name_only: bool = False) -> str | list[str]:
    if name_only:
        return "name"
    return ["name", "value"]

The intention here is pretty clear: The overload narrows a parameter to Literal[True], but the implementation has the actual default as False. Other type checkers don't treat this pattern as an error.

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN24AbjEpRcqTABo6AGQgMRqKAB10qgAJCRYiaswwwdYqkpwYAfQYm2MBgAp0qGhdzoopRLPmKoAbQAqlACuMAC6dAC8dIQxAJR0ALQAfHRwDJSeMYR0dADERqSUBu50AGIAChpaouKYegZGJmaW1rYOTi5uHnR4uFCR0XGJKWmUdAA%2BdFAQab6joZkx9YbGphZWlDb2js7mru6evf1RpUpm8cmp6RNTMwxz6QuqOTkQhjudB88vP0UMQZR0HRlCAPiDvjk-gCgb4QWCQNIQYIlCEQaEESAyEUwO5CAxaFAKPlyoViqRUhgcAQ6ABjVyQNgA1AMCCuQiqfIAZRgMDoAAsGAxiHBEAB6UVYsmEXhsUUwdCizC4GlwUV09AMpks1yiuhgXh0VDI6CobCwWn0iCMyjM1lA3DEbXoODs9BkBh81wJYSmO0DEEAZkIAEYAEzg9C%2BETUUyhVRBdBcHh8GCYBKYCBFGks4QDADkVvQvBgedURYYCSKAEcgpnUwkANYwUgJVA0mnwOD5gDuJnQpfQIAAvpIQG2czBStAYBQ0Fg8EQyMOgA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    typecheckingusabilityUsability & readiness issues identified with running Pyrefly on top OSS projectsv1-consider-addingTop-ranked but not in V1 milestone (consider adding)

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions