Skip to content

[ty] Suppress parenthesis completions for enum classes - #30441

Open
trim21 wants to merge 1 commit into
astral-sh:mainfrom
trim21:ty/enum-member-completion
Open

trim21 wants to merge 1 commit into
astral-sh:mainfrom
trim21:ty/enum-member-completion

Conversation

@trim21

@trim21 trim21 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes astral-sh/ty#3712.

With completions.completeFunctionParentheses enabled, accepting a class completion also inserts (). For enums that is almost never what the user wants: typing Color is nearly always a step towards Color.RED, and Color() both discards the member access and puts the cursor inside the parentheses.

Class completions for enum classes now skip the parentheses. This covers Enum, StrEnum, IntEnum, enum subclasses and subclasses of subclasses; non-enum classes are unchanged.

This follows the approach a maintainer suggested in the issue — @MichaReiser:

I don't think we should add a configuration option. Instead, we can suppress the completion for enums.

It also picks up #25832, which tried the same thing but was closed before merging.

Test Plan

New snapshot tests in crates/ty_ide/src/completion.rs cover Enum, an enum subclass, a subclass of a subclass, StrEnum and IntEnum, plus the existing complete_class_parentheses test for a plain class.

  • cargo test -p ty_ide --lib
  • cargo test -p ty_server --test e2e completions

@trim21
trim21 requested review from a team as code owners November 14, 2026 17:35
@astral-automations-bot astral-automations-bot Bot added the ty The ty type checker label Nov 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty The ty type checker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

It should be possible to disable completeFunctionParentheses on enums/classes

1 participant