There was an error while loading. Please reload this page.
@property
Complex union types (int | str | tuple[int, str] | None) are simplified to Unknown when the method is accessed through @property
int | str | tuple[int, str] | None
Unknown
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
This only occurs when the union type has 4 or more members. Smaller unions (2-3 types) are inferred correctly.
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN2UYANxiooAfSbEYAHXRy5AYyio4cOgDFcuRHLr66mGGDrZUlABRwYUMABo6cLsVjiArugi50iTun4APo4MlA6KtC4w%2BO6e3r6sgcGUdEEMbpEA2gkOcCEAuil0AHLeMHQAvMWlAJS%2BhPUK8ujKqupauACyGKhsMJS66AaGxnTi4qwQDGNWNmC1ekMG1raEYNoVmtoW1Y1DAALE1NJ8pAv6RiZmlstzA4sGgmmUgzer2oRXjXKCImKSzDALO0uugen1th9zNV9ABiATCUSwTCMAG%2BGa2XztHLOVweLw%2BPyJXKhOjhbiwaJ4uJ0ACq6AA1uhcAB3QaVEroGDQgC0AD4qpy5CA7CA3AxoHASORECA4TTxVBJqQ6GAPIpxd44I0LireDRUFN0G4aNhwfh4v4efziXcHjAnoMwDIQEVjab%2BnRgPgAL7OoUisiCMBQUiEBi0KAUOEABVIQZDjgwOAIpO8kDYbkoBvxhDkcIAyjAygALBgMYhwRAAeirgeMIcIvDYVZg6CrmFwijgVfC6HTmez3iruuSqCEqGgqGwsFTfYgGazGsGuGIS8lcjIDGL3m5IkoTm8G2dAGZCABGABMfvQIG9ItQ6ogIg00BgFDQWDwRDIt6AA
No response
Describe the Bug
Complex union types (
int | str | tuple[int, str] | None) are simplified toUnknownwhen the method is accessed through@propertyPython: 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