Skip to content

Type information lost when accessing method via @property #3958

Description

@anci3ntr0ck

Describe the Bug

Complex union types (int | str | tuple[int, str] | None) are simplified to Unknown when the method is accessed through @property

from typing import reveal_type


class Foo:
    def bar(self, simple_union: int | str, complex_union: int | str | tuple[int, str] | None = None): ...


class FooManager:
    def __init__(self):
        self.foo = Foo()

    @property
    def bar(self):
        return self.foo.bar


reveal_type(FooManager().bar)  # revealed type: (self: Foo, simple_union: int | str, complex_union: Unknown = None) -> None

Python: 3.12

Note

This only occurs when the union type has 4 or more members. Smaller unions (2-3 types) are inferred correctly.

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN2UYANxiooAfSbEYAHXRy5AYyio4cOgDFcuRHLr66mGGDrZUlABRwYUMABo6cLsVjiArugi50iTun4APo4MlA6KtC4w%2BO6e3r6sgcGUdEEMbpEA2gkOcCEAuil0AHLeMHQAvMWlAJS%2BhPUK8ujKqupauACyGKhsMJS66AaGxnTi4qwQDGNWNmC1ekMG1raEYNoVmtoW1Y1DAALE1NJ8pAv6RiZmlstzA4sGgmmUgzer2oRXjXKCImKSzDALO0uugen1th9zNV9ABiATCUSwTCMAG%2BGa2XztHLOVweLw%2BPyJXKhOjhbiwaJ4uJ0ACq6AA1uhcAB3QaVEroGDQgC0AD4qpy5CA7CA3AxoHASORECA4TTxVBJqQ6GAPIpxd44I0LireDRUFN0G4aNhwfh4v4efziXcHjAnoMwDIQEVjab%2BnRgPgAL7OoUisiCMBQUiEBi0KAUOEABVIQZDjgwOAIpO8kDYbkoBvxhDkcIAyjAygALBgMYhwRAAeirgeMIcIvDYVZg6CrmFwijgVfC6HTmez3iruuSqCEqGgqGwsFTfYgGazGsGuGIS8lcjIDGL3m5IkoTm8G2dAGZCABGABMfvQIG9ItQ6ogIg00BgFDQWDwRDIt6AA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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