Skip to content

Accessing Enum value when values are repeated results in incorrect unresolved-attribute error #1293

@MatthewCane

Description

@MatthewCane

Summary

When an Enum class definition contains keys with repeated values, ty reports an incorrect unresolved-attribute error when accessing the value on the 3rd or greater key.

Minimal Example:

from enum import Enum


class example_enum(Enum):
    foo = "foo"
    bar = "foo"
    baz = "foo"
    boo = "foo"


example_enum.foo.value  # This is fine
example_enum.bar.value  # This is fine
example_enum.baz.value  # unresolved-attribute: Type `Literal[example_enum.bar]` has no attribute `value`
example_enum.boo.value  # unresolved-attribute: Type `Literal[example_enum.bar]` has no attribute `value`

https://play.ty.dev/e5e328e2-5b36-4fa9-842f-8a281db30d7b

Version

ty 0.0.1-alpha.21 (ef52a19 2025-09-19)

Metadata

Metadata

Assignees

Labels

attribute accessInstance attributes, class attributes, etc.bugSomething isn't workingenums

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions